Java obtains the CLOB field in Oracle and converts it to String: try {PreparedStatementstmtsession. connection (). prepareStatement (SQL); Result
Java obtains the CLOB field in Oracle and converts it to String: try {PreparedStatement stmt = session. connection (). prepareStatement (SQL); Result
Homepage → Database Technology
Background:
Read News
Java obtains the CLOB field in Oracle and converts it to String
[Date:] Source: Linux community Author: Linux [Font:]
Java obtains the CLOB field in Oracle and converts it to String:
Try {
PreparedStatement stmt = session. connection (). prepareStatement (SQL );
ResultSet rs = stmt.exe cuteQuery ();
While (rs. next ())
{
Clob clob = (Clob) rs. getObject (1 );
Result = ClobToString (clob );
}
} Catch (HibernateException e ){
E. printStackTrace ();
} Catch (SQLException e ){
E. printStackTrace ();
} Catch (IOException e ){
E. printStackTrace ();
} Finally {
Session. close ();
}
// Convert oracle. SQL. Clob type to String type
Public String ClobToString (Clob clob) throws SQLException, IOException {
String reString = "";
Reader is = clob. getCharacterStream (); // get the stream
BufferedReader br = new BufferedReader (is );
String s = br. readLine ();
StringBuffer sb = new StringBuffer ();
While (s! = Null) {// execute the loop to retrieve all strings and pay the value to StringBuffer, which is converted from StringBuffer to STRING.
Sb. append (s );
S = br. readLine ();
}
ReString = sb. toString ();
Return reString;
}
0
Oracle date timestamp millisecond-time function Summary
Install MySQL 7.2 in FreeBSD 4.0
Oracle Basics
Image Information
View All comments in this article (0)
Comments
Latest Information
Popular this week
Introduction to Linux community-advertisement service-website map-help Info-contact us
The articles published on this site (LinuxIDC) do not mean that they agree with the statement or description. They only provide more information and do not constitute any suggestions.
Copyright©2006-2011 Linux community All rights reserved Zhejiang ICP backup No. 06018118
,