I am running this code but I don't know what is wrong in this code.
I define the statement with field SENSITIVE & UPDATABLE but when I run the code this error message appears in the console:
Result Set not updatable.This result set must come from a statement that was created with a result set type of ResultSet.CONCUR_UPDATABLE, the query must select only one table, and must select all primary keys from that table.
See the JDBC 2.1 API Specification, section 5.6 for more details.
Process finished with exit code 0
Please guide me. Here is the code:
import java.sql.*;
public class Main
{
public static void main(String[] args)
{
Connection con=getConnection();
try
{
String query="Select title from movie1";
Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
ResultSet rs=stmt.executeQuery(query);
rs.absolute(13);
rs.deleteRow();
}
catch (SQLException e)
{
System.out.println(e.getMessage());
}
}
private static Connection getConnection()
{
Connection con=null;
try
{
Class.forName("com.mysql.jdbc.Driver");
String url="jdbc:mysql://localhost/Movies";
String user="user4545";
String pw="j4545j";
con= DriverManager.getConnection(url,user,pw);
}
catch (ClassNotFoundException e)
{
System.out.println(e.getMessage());
System.exit(0);
}
catch (SQLException e)
{
System.out.println("SQL Exeption happend.");
System.exit(0);
}
return con;
}
}