Chapter 10: JDBC Flashcards
Enumerate the four interfaces in JDBC
Connection, Driver, Statement, ResultSet
Parts of JDBC URL
: :
jdbc:oracle:thin:@192168.1.18:1521:orcl
what is Class.forName() method for?
It loads the class and throws ClassNotFoundException if the class is not available.
Two ways to create a statement?
conn. createStatement() and
conn. createStatement(ResultSet type, ResultSet concurrency)
ResultSet type, You can go through the data once in the order in which it was retrieved.
ResultSet.TYPE_FORWARD_ONLY
ResultSet Type, Allows you to move forward and backward to the resultSet but the result set is static.
ResultSet.TYPE_SCROLL_INSENSITIVE
ResultSet Type, Allows you to move backward and forward in the ResultSet but you see the latest data when scrolling
ResultSet.TYPE_SCROLL_SENSITIVE Not many database driver and database support this feature.
ResultSet Concurrency Mode, you cannot update the result set.
ResultSet.CONCUR_READ_ONLY
ResultSet Concurrency Mode, you can update the result set.
ResultSet.CONCUR_UPDATABLE
statement method, you can execute a query or update statement and it will return a boolean if there is a result set.
statement.execute(“Query”);
statement method, executes a query and returns a result set
statement.executeQuery(“Query”);
statement method, executes an update, delete, and insert. returns how many rows are affected.
statement.executeUPdate(“Query”);
9 get methods in ResultSet.
getBoolean getDate getDouble getInt getLong getObject getString getTime getTimeStamp