Book Image

JDBC 4.0 and Oracle JDeveloper for J2EE Development

Book Image

JDBC 4.0 and Oracle JDeveloper for J2EE Development

Overview of this book

Table of Contents (20 chapters)
JDBC 4.0 and Oracle JDeveloper for J2EE Development
Credits
About the Author
About the Reviewer
Preface

Connection Interface


The Connection interface represents a connection with the database. SQL statements may be run in a connection session by using a Statement object. A Connection object is in auto-commit mode, by default. In the auto-commit mode, changes are committed to the database after an SQL statement is executed. The auto-commit mode can be modified by calling the setAutoCommit(boolean autoCommit) method. For example, auto-commit may be set to false :

connection.setAutoCommit(false);

If auto-commit is set to false, it would be required to commit changes by calling the commit() method:

connection.commit();

A Connection object can be set to read-only by calling the setReadOnly() method:

connection.setReadOnly(true);

If a Connection object is not required, close the connection by calling the close() method:

connection.close();

The following table discusses the methods in JDBC 4.0 that have been added to the Connection interface.

Method

Description

createArrayOf()

Creates a java.sql.Array object. java.sql.Array is the Java mapping for the SQL data type, ARRAY. The SQL3 data type ARRAY stores an array in a column.

createBlob()

Creates a Blob object.

createClob()

Creates a Clob object.

createNClob()

Creates an NClob object.

createSQLXML()

Creates a SQLXML object.

createStruct()

Creates a Struct object.

isValid()

Tests the validity of a connection.

getClientInfo()

Overloaded method returns a client info property, or a list of client info properties. Client info represents information, such as user name and application name about the client.

setClientInfo()

Overloaded method sets client info.