Here is my code
Connection con = null;
PreparedStatement ps = null;
InputStream is = null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
con = DriverManager.
getConnection("jdbc:oracle:thin:@<hostname>:<port num>:<DB name>"
,"user","password");
ps = con.prepareCall("insert into student_profile values (?,?)");
ps.setInt(1, 101);
is = new FileInputStream(new File("Student_img.jpg"));
ps.setBinaryStream(2, is);
int count = ps.executeUpdate();
System.out.println("Count: "+count);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally{
try{
if(is != null) is.close();
if(ps != null) ps.close();
if(con != null) con.close();
} catch(Exception ex){}
}
}
}
I Don't Know where I am wrong but there is an error in executing the code Exception I get
- Exception in thread "main" java.lang.AbstractMethodError: Method oracle/jdbc/driver/OraclePreparedStatementWrapper.setBlob(ILjava/io/InputStream;)V is abstract at oracle.jdbc.driver.OraclePreparedStatementWrapper.setBlob(OraclePreparedStatementWrapper.java)