Reputation: 213
I am currently experimenting on my own, learning some JDBC and how to persist objects to a database. Right now I am trying to upload a Document to the database. I am getting the following error:
Exception in thread "main" java.lang.AbstractMethodError: Method com/mysql/jdbc/PreparedStatement.setClob(ILjava/io/Reader;)V is abstract
at com.mysql.jdbc.PreparedStatement.setClob(PreparedStatement.java)
at dao.StudentDAO.uploadResume(StudentDAO.java:156)
at controller.Test.main(Test.java:30)
Have no clue why this is happening, can someone help me see the error? Here is some of my code:
// this is in my studentDAO class:
private static final String SQL_UPDATE_RESUME =
"UPDATE students
SET resume = ?
WHERE socialSecNumber = ?";
public boolean uploadResume(Reader r) {
PreparedStatement pst;
//Reader file;
try{
pst = con.getConnection().prepareStatement(SQL_UPDATE_RESUME);
//file = r;
pst.setClob(1, r);
}
catch(SQLException e){
System.out.println("Error when uploading the resume: " + e);
}
finally{
con.closeConnection();
}
return true;
}
public class Test {
public static void main(String[] args) {
File file = new File("C:/Users/Carlos L/Desktop/Resume.docx");
Reader r = null;
try {
r = new FileReader(file);
} catch (FileNotFoundException e) {
System.out.println("Error when locating the file: "+ e);
}
sdao.uploadResume(r);
}
}
Upvotes: 3
Views: 909
Reputation: 159096
PreparedStatement.setClob(int parameterIndex, Reader reader)
was adding in Java 6, and you're using the JDBC driver from before that.
Upgrade to a Java 6 compatible driver, and your code will work.
Upvotes: 2