详解jdbc实现对CLOB和BLOB数据类型的操作1、 读取操作CLOB //获得数据库连接 Connection con = ConnectionFactory.getConnection(); con.se
详解jdbc实现对CLOB和BLOB数据类型的操作
1、 读取操作
CLOB
//获得数据库连接 Connection con = ConnectionFactory.getConnection(); con.setAutoCommit(false); Statement st = con.createStatement(); //不需要“for update” ResultSet rs = st.executeQuery("select CLOBATTR from TESTCLOB where ID=1"); if (rs.next()) { java.sql.Clob clob = rs.getClob("CLOBATTR"); Reader inStream = clob.getCharacterStream(); char[] c = new char[(int) clob.length()]; inStream.read(c); //data是读出并需要返回的数据,类型是String data = new String(c); inStream.close(); } inStream.close(); con.commit(); con.close();
--结束END--
本文标题: 详解jdbc实现对CLOB和BLOB数据类型的操作
本文链接: https://www.lsjlt.com/news/224349.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-04-29
2024-04-29
2024-04-29
2024-04-29
2024-04-29
2024-04-29
2024-04-29
2024-04-29
2024-04-29
2024-04-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0