Guest User

Untitled

a guest
Aug 2nd, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. Error while inserting image in database
  2. Exception in thread "main" java.lang.AbstractMethodError: oracle.jdbc.driver.OraclePreparedStatement.setBlob(ILjava/io/InputStream;)V
  3. at ImageStore.main(ImageStore.java:28)
  4.  
  5. public class ImageStore {
  6.  
  7. /**
  8. * @param args
  9. * @throws Exception
  10. */
  11. public static void main(String[] args) throws Exception {
  12. Class.forName("oracle.jdbc.driver.OracleDriver");
  13.  
  14. Connection con = DriverManager
  15. .getConnection("jdbc:oracle:thin:@localhost:1521:orcl",
  16. "usrname", "password");
  17.  
  18. String sql="update items set image=? where id=1";
  19. //String sql="select * from price";
  20. PreparedStatement ps=con.prepareStatement(sql);
  21. File f=new File("E:/Images/s.jpg");
  22. InputStream fos= new FileInputStream(f);
  23.  
  24. ps.setBlob(1, fos);
  25.  
  26. ps.execute();
  27. /*while(rs.next())
  28. System.out.println(rs.getInt(1));
  29. */
  30. ps.close();
  31. con.close();
  32.  
  33.  
  34. }
Add Comment
Please, Sign In to add comment