Given that method getConnection()
returns a valid Connection object, the query variable defines a valid SQL statement, and class Main prints 0, select the options for the following code that can be correct individually:.
class Main {/* w w w. jav a 2s .c om*/ public static void main(String[] args) { try { String query = "....."; //line1 Connection con = getConnection(); PreparedStatement statement = con.prepareStatement(query); System.out.println( statement.executeUpdate()); } catch (SQLException e) { System.out.println(e); } } }
b, c, d
You can't use method executeUpdate()
to execute a SQL SELECT query.
If you do, you'll get a SQLException with a similar message:.
java.sql.SQLException: Can not issue executeUpdate() for SELECTs
Similarly, you can't execute data deletion and modification queries with method executeQuery()
.
If you do so, you'll get a SQLException.