时间:2021-07-01 10:21:17 帮助过:71人阅读
在Oracle中是Long型,在Java中如何进行获取,插入和修改:网上说可以使用Reader reader = rs.getCharacterStream(1); 获得Long型
在Oracle中是Long型,在Java中如何进行获取,,插入和修改:
网上说可以使用Reader reader = rs.getCharacterStream(1); 获得Long型数据,但是我直接使用ds.getString()来获取并未报错,而且数据库也是9i的,这地方不清楚,还有待研究,先写上
修改Long数据:使用
PreparedStatement pstam = null;
pstam.setCharacterStream(n, new StringReader(value),value.length);
例如:
public boolean editNewsById(String row_id,HashMap map) {
boolean bool = false;
int count = 0;
Connection conn = BDUtil.getConnection();
PreparedStatement pstam = null;
StringBuffer sql = new StringBuffer();
sql.append("update cd_news set news_name=?,describute_news=?,summary_news=? where row_id=? ");
try {
pstam = conn.prepareStatement(sql.toString());
pstam.setString(1, map.get("title_news").toString());
pstam.setCharacterStream(2, new StringReader(map.get("describute_news").toString()),map.get("describute_news").toString().length());
pstam.setString(3,map.get("summary_news").toString());
pstam.setString(4, row_id);
count = pstam.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}finally{
BDUtil.close(conn, pstam, null);
}
if(count>0) {
bool = true;
}
return bool;
}
向数据库中增加Long信息时也是用
pstam.setCharacterStream(n, new StringReader(value),value.length); 同上