Java Questions
Java Questions
executeUpdate?
Statement execute(String query) is used to execute any SQL query and it returns
TRUE if the result is an ResultSet such as running Select queries. The output is
FALSE when there is no ResultSet object such as running Insert or Update
queries. We can use getResultSet() to get the ResultSet
and getUpdateCount() method to retrieve the update count.
You should use execute() method only when you are not sure about the type of
statement else use executeQuery or executeUpdate method.
JDBC statements are basically the statements which are used to send SQL
commands to the database and retrieve data back from the database. Various
methods like execute(), executeUpdate(), executeQuery, etc. are provided by
JDBC to interact with the database.
1. Statement: Used for general purpose access to the database and executes
a static SQL query at runtime.
2. PreparedStatement: Used to provide input parameters to the query during
execution.
3. CallableStatement: Used to access the database stored procedures and
helps in accepting runtime parameters.
Java is called platform independent because of its byte codes which can run on
any system irrespective of its underlying operating system.