Home > Database > Mysql Tutorial > Java中如何对Oracle的Long型数据操作

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 16:59:37
Original
1585 people have browsed it

在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); 同上

linux

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template