JDBC Connection Interface Flashcards Preview

OCP > JDBC Connection Interface > Flashcards

Flashcards in JDBC Connection Interface Deck (18):
1

Creates a statement that can b e used to send SQL statements to the database.

Statement createStatement()

2

Creates a PreparedStatement object that can contain SQL statements. The SQL statement can have IN parameters; they may contain '?' symbol(s), which are used as placeholders for passing actual values later.

PreparedStatement prepareStatement(String sql)

3

Creates a CallableStatement object for calling stored procedures in the database. The SQL statement can have IN or OUT parameters; they may contain '?' symbol(s), which are used as placeholders for passing actual values later.

CallableStatement prepareCall(String sql)

4

Gets the DataBaseMetaData object. This metadata contains useful information, such as schema information, table information etc., which is especially useful when you don't know the underlying database.

DatabaseMetaData getMetaData()

5

Returns a Clob object. CLOB (Character Large Object) is a built in type in SQL; it can be used to store a column value in a row of a database table.

Clob createClob()

6

Returns a blob object. BLOB (Binary Large Object) is a built in type in SQL; it can b e used to store a column value in a row of a database table.

Blob createBlob()

7

When passed the schema name, it sets this Connection object to the database schema to access.

void setSchema(String schema)

8

Returns the schema name of the database associated with this connection object; returns null if no schema is associated with it.

String getSchema()

9

Gets a connection object from the driver manager.

DriverManager.getConnection()

10

Closes the connection. Automatically called if try-with-resources is used.

close()

11

Sets the auto-commit mode to true or false. By default, this is set to true.

void setAutoCommit(boolean autoCommit)

12

Returns the auto commit mode currently set (true means auto commit mode is set, false means it is not).

boolean getAutoCommit()

13

Creates a Savepoint object in the current transaction and returns that object.

Savepoint setSavepoint()

14

Creates a Savepoint object in the current transaction with a name associated with it and returns that object.

Savepoint setSavepoint(String name)

15

Removes the given Savepoint object and subsequent Savepoint objects from the current transaction.

void releaseSavepoint(Savepoint savepoint)

16

Rolls back to the given Savepoint state. Throws a SQLException if the rollback cannot be done.

void rollback(Savepoint savepoint)

17

Rolls back all changes made in the current transaction. Throws a SQLException if there is nothing to roll back, like if auto-commit mode is on.

void rollback()

18

Commits all changes done so far in the transaction to the database.

void commit()