Studydroid is shutting down on January 1st, 2019

Bookmark and Share

Front Back
What are the kinds of Statement objects in JDBC?
Statement, PreparedStatement, CallableStatement
What does the JDBC Statement class represent?
Just a basic SQL statement.
What does the JDBC PreparedStatement class represent?
Similar to the JDBC Statement, but it has been precompiled to improve performance for multiple calls.
What does the JDBC CallableStatement class represent?
Used to call stored procedures in the database.
How do you get a JDBC Statement object?
use method createStatement() from a Connection object.
What is are the basic steps in JDBC to execute a SQL statement?
1. Load the driver class (e.g., Class.forName("databaseDriverClass")2. Connect to the database (e.g., Connection con = DriverManager.getConnection("url","user","password")3. Create a Statement object from the connection object (e.g., Statement stmt = con.createStatement())4. Execute the statement and retrieve the result (e.g., ResultSet rs = stmt.executeQuery("SELECT FIRST_NAME FROM EMPLOYEES"))5. Use the results (e.g., a ResultSet list of rows) as needed.6. Close all the instances. Use the close() mehtod of the result set, the statement and the connection.
What kind of methods does the JDBC Statement object has?
1. executeQuery() to execute a query. Returns a ResultSet object.2. executeUpdate() to modify or delete rows.3. execute(). The kind of statement (query or update) is unknown at run time. It returns true for is the result is associated with a valid Statement
For the JDB execute() method, it returns true or if the statement is valid. What other methodes are used?
1. getResultTest()2. getUpdateCount()
How do you know the number of updated rows in JDBC?
Use statementObject.getResultSet()
How do you get multiple result sets?
Use statementObject.getResultSet()2. If getResultSet() returns null, that means that it was a data update.. If getResultSet() is not null, then a result set was generated, and can be retrieved.4. Now we need to check if there are more results. Use statementObject.getMoreResults() and statementObject.getUpdateCount() == -1. If both conditions are true, then there are no more result lists available, so the loope scanning for more results should stop.
x of y cards