I'm trying upload image to database using Java.
I've used following code to do that work.
File file= new File("image.jpg");
FileInputStream fis = new FileInputStream("image.jpg");
String query = "insert into mytable(id,image) values(?, ?)";
PreparedStatement stmt = dbConn.prepareStatement(query);
stmt.setInt(1, sid);
stmt.setBinaryStream(2, fis, (int) file.length());
stmt.executeUpdate();
But it throws me this error.
java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0)
Please help me to solve this problem.