Java中如何对Oracle的Long型数据操作

2014-11-24 17:59:50 · 作者: · 浏览: 5

网上说可以使用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); 同上