import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class Test {
/**
* @param args
*/
@SuppressWarnings("unused")
public static void main(String[] args) {
Connection conn = null;
Statement sql = null;
ResultSet rs = null;
try {
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
String sourceURL = "数据库地址";
String user = "dataBaseUser";
String password = "dataBasepassword";
conn = DriverManager.getConnection(sourceURL, user, password);
sql = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sqlstr = "select demo from testDatabase where id = 1";
rs = sql.executeQuery(sqlstr);
while (rs.next()) {
oracle.sql.BLOB blob = (oracle.sql.BLOB) rs.getBlob("INPUTCONTENT");
String reString = "";
if (blob != null) {
InputStream in = blob.getBinaryStream();
byte[] buff = new byte[1024];
for (int i = 0; (i = in.read(buff)) > 0;) {
reString = reString + new String(buff);
}
in.close();
}
System.out.println(reString);
}
}catch (Exception e) {
}
finally {
rs.close();
sql.close();
conn.close();
}
}
catch (SQLException e) {
System.out.println("SQLException.");
}
}
}