当我从数据库中读取blob数据时,得到的值为null
。什么可能是这个问题?有人能帮助我吗?getBinaryStream问题(索引)
Connection con = null;
PreparedStatement psStmt = null;
ResultSet rs = null;
try {
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
con =
DriverManager.getConnection("jdbc:oracle:thin:@MyDatabase:1535:XE","password","password");
System.out.println("connection established"+con);
psStmt = con
.prepareStatement("Select Photo from Person where Firstname=?");
int i = 1;
psStmt.setLong(1, "Nani");
rs = null;
rs = psStmt.executeQuery();
InputStream inputStream = null;
while (rs.next()) {
inputStream = rs.getBinaryStream(1);
//Blob blob = rs.getBlob(1);
//Blob blob1 = (Blob)rs.getObject(1);
//System.out.println("blob length "+blob1);//rs.getString(1);
}
System.out.println("bytessssssss "+inputStream);//here i am getting null value.
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
感谢您的回答。我更新了我的问题,请通过。尽管我遇到了同样的问题,但我已经完成了你所提到的任何事情。 – Nani 2014-09-29 08:13:12
@Nani可以更改InputStream inputStream = null;到InputStream inputStream = new InputStream()plz? – 2014-09-29 08:16:30
@Nani摆脱rs = null;在你的try catch块内 – 2014-09-29 08:18:49