0

It's giving error

"Exception in thread "main" java.lang.AbstractMethodError: 
Method com/mysql/jdbc/ServerPreparedStatement.setBinaryStream(ILjava/io/InputStream;)V is abstract
    at com.mysql.jdbc.ServerPreparedStatement.setBinaryStream(ServerPreparedStatement.java)
    at jdbc.demo.main(demo.java:21)".

I have added my code snippet as follow, can you please give me an insight what am I doing wrong?

import java.io.File;
import java.io.FileInputStream;
import java.sql.*;
public class demo{

    public static void main(String args[]) throws Exception{

        String url = "jdbc:mysql://localhost:3306/tutorial1";
        String name = "root";
        String pass = "rubyonrails$";
        Class.forName("com.mysql.jdbc.Driver");
        Connection con = DriverManager.getConnection(url,name,pass);

        String sql = "update binarylargeobject set resume=? where id=1";
        PreparedStatement st = con.prepareStatement(sql);
        File file = new File("C:\\Users\\USER\\Desktop\\vid.pdf");
        FileInputStream input = new FileInputStream(file);
        st.setBinaryStream(1,input);
        st.executeUpdate();

   }

}
KOUSIK MANDAL
  • 2,002
  • 1
  • 21
  • 46
  • READ THIS-: http://stackoverflow.com/questions/1194990/why-do-i-get-java-lang-abstractmethoderror-when-trying-to-load-a-blob-in-the-db – Tushar Sharma Mar 22 '17 at 14:17

1 Answers1

1

AbstractMethodError that you happen to see in your case means that the MySQL JDBC Connector/J driver you use has not implemented the method setBinaryStream().

There is a nice article that I've come across when I tried to dig deeper here, you must take a look at it.

What is observed from the website above and various others is to use MySQL JDBC Connector/J version over 5.1.36 (a JDBC type 4 driver).

Hope you are able to solve your problem with the suggestions above.

N00b Pr0grammer
  • 4,503
  • 5
  • 32
  • 46