Class JdbcConnection

A JDBC Connection. For documentation of this class, see java.sql.Connection.

Methods

MethodReturn typeBrief description
clearWarnings()voidFor documentation of this method, see java.sql.Connection#clearWarnings().
close()voidRelease the JdbcConnection's database and all associated resources.
commit()voidMakes all pending changes permanent, releases database locks held by this JdbcConnection.
createArrayOf(typeName, elements)JdbcArrayFor documentation of this method, see java.sql.Connection#createArrayOf(String, Object[]).
createBlob()JdbcBlobConstructs a JdbcBlob instance The object returned initially contains no data.
createClob()JdbcClobFor documentation of this method, see java.sql.Connection#createClob().
createNClob()JdbcClobFor documentation of this method, see java.sql.Connection#createNClob().
createSQLXML()JdbcSQLXMLFor documentation of this method, see java.sql.Connection#createSQLXML().
createStatement()JdbcStatementCreates a JdbcStatement object for sending SQL statements to the database.
createStatement(resultSetType, resultSetConcurrency)JdbcStatementCreates a JdbcStatement object for sending SQL statements to the database.
createStatement(resultSetType, resultSetConcurrency, resultSetHoldability)JdbcStatementCreates a JdbcStatement object for sending SQL statements to the database.
createStruct(typeName, attributes)JdbcStructFor documentation of this method, see java.sql.Connection#createStruct(String, Object[]).
getAutoCommit()BooleanFor documentation of this method, see java.sql.Connection#getAutoCommit().
getCatalog()StringFor documentation of this method, see java.sql.Connection#getCatalog().
getHoldability()IntegerFor documentation of this method, see java.sql.Connection#getHoldability().
getMetaData()JdbcDatabaseMetaDataFor documentation of this method, see java.sql.Connection#getMetaData().
getTransactionIsolation()IntegerFor documentation of this method, see java.sql.Connection#getTransactionIsolation().
getWarnings()String[]For documentation of this method, see java.sql.Connection#getWarnings().
isClosed()BooleanFor documentation of this method, see java.sql.Connection#isClosed().
isReadOnly()BooleanFor documentation of this method, see java.sql.Connection#isReadOnly().
isValid(timeout)BooleanFor documentation of this method, see java.sql.Connection#isValid(int).
nativeSQL(sql)StringFor documentation of this method, see java.sql.Connection#nativeSQL(String).
prepareCall(sql)JdbcCallableStatementFor documentation of this method, see java.sql.Connection#prepareCall(String).
prepareCall(sql, resultSetType, resultSetConcurrency)JdbcCallableStatementFor documentation of this method, see java.sql.Connection#prepareCall(String, int, int).
prepareCall(sql, resultSetType, resultSetConcurrency, resultSetHoldability)JdbcCallableStatementFor documentation of this method, see java.sql.Connection#prepareCall(String, int, int, int).
prepareStatement(sql)JdbcPreparedStatementFor documentation of this method, see java.sql.Connection#prepareStatement(String).
prepareStatement(sql, autoGeneratedKeys)JdbcPreparedStatementFor documentation of this method, see java.sql.Connection#prepareStatement(String, int).
prepareStatement(sql, resultSetType, resultSetConcurrency)JdbcPreparedStatementFor documentation of this method, see java.sql.Connection#prepareStatement(String, int, int).
prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability)JdbcPreparedStatementFor documentation of this method, see java.sql.Connection#prepareStatement(String, int, int, int).
prepareStatementByIndex(sql, indices)JdbcPreparedStatementFor documentation of this method, see java.sql.Connection#prepareStatement(String, int[]).
prepareStatementByName(sql, columnNames)JdbcPreparedStatementFor documentation of this method, see java.sql.Connection#prepareStatement(String, String[]).
releaseSavepoint(savepoint)voidFor documentation of this method, see java.sql.Connection#releaseSavepoint(java.sql.Savepoint).
rollback()voidFor documentation of this method, see java.sql.Connection#rollback().
rollback(savepoint)voidFor documentation of this method, see java.sql.Connection#rollback(java.sql.Savepoint).
setAutoCommit(autoCommit)voidFor documentation of this method, see java.sql.Connection#setAutoCommit(boolean).
setCatalog(catalog)voidFor documentation of this method, see java.sql.Connection#setCatalog(String).
setHoldability(holdability)voidFor documentation of this method, see java.sql.Connection#setHoldability(int).
setReadOnly(readOnly)voidFor documentation of this method, see java.sql.Connection#setReadOnly(boolean).
setSavepoint()JdbcSavepointFor documentation of this method, see java.sql.Connection#setSavepoint().
setSavepoint(name)JdbcSavepointFor documentation of this method, see java.sql.Connection#setSavepoint(String).
setTransactionIsolation(level)voidFor documentation of this method, see java.sql.Connection#setTransactionIsolation(int).

Detailed documentation

clearWarnings()

For documentation of this method, see java.sql.Connection#clearWarnings().


close()

Release the JdbcConnection's database and all associated resources.

 
var conn = Jdbc.getConnection("jdbc:mysql://<host>:<port>/<instance>", "user", "password");
 conn.close();
 

See also


commit()

Makes all pending changes permanent, releases database locks held by this JdbcConnection.

 
var conn = Jdbc.getConnection("jdbc:mysql://<host>:<port>/<instance>", "user", "password");
 conn.setAutoCommit(false);
 var stmt = conn.prepareStatement("insert into person (lname,fname) values (?,?)");
 var start = new Date();
 for (var i = 0; i < 5000; i++) {
   // Objects are accessed using 1-based indexing
   stmt.setObject(1, 'firstName' + i);
   stmt.setObject(2, 'lastName' + i);
   stmt.addBatch();
 }
 var res = stmt.executeBatch();
 conn.commit(); // When this returns, this is when changes are actually commited
 conn.close();
 

See also


createArrayOf(typeName, elements)

For documentation of this method, see java.sql.Connection#createArrayOf(String, Object[]).

Parameters

NameTypeDescription
typeNameString
elementsObject[]

Return

JdbcArray


createBlob()

Constructs a JdbcBlob instance The object returned initially contains no data. The setBytes methods of JdbcBlob may be used to set the data it should contain. Note that the blob used here is not the same as the blob created with Utilities.newBlob(data). To convert between the two formats, use the defined getBytes() and setBytes() methods. Alternatively, both JdbcBlob and JdbcClob provide a getAppsScriptBlob() convenience method for converting to a format that can be used by Apps Script.

Return

JdbcBlob

See also


createClob()

For documentation of this method, see java.sql.Connection#createClob().

Return

JdbcClob


createNClob()

For documentation of this method, see java.sql.Connection#createNClob().

Return

JdbcClob


createSQLXML()

For documentation of this method, see java.sql.Connection#createSQLXML().

Return

JdbcSQLXML


createStatement()

Creates a JdbcStatement object for sending SQL statements to the database.

 
// This sample code assumes authentication is off
 var conn = Jdbc.getConnection("jdbc:mysql://<host>:3306/<instance>")
 var stmt = conn.createStatement();

 stmt.setMaxRows(100);
 var rs = stmt.execute("select * from person");

 while(rs.next()) {
   // Do something
 }

 rs.close();
 stmt.close();
 conn.close();

Return

JdbcStatement — a JdbcStatement instance to execute queries with

See also


createStatement(resultSetType, resultSetConcurrency)

Creates a JdbcStatement object for sending SQL statements to the database. This version allows the result set type and concurrency to be overridden.

 
// This sample code assumes authentication is off
 // For more information about this method, see documentation here:
 //  http://docs.oracle.com/javase/6/docs/api/java/sql/Connection.html#createStatement(int, int)
 var conn = Jdbc.getConnection("jdbc:mysql://<host>:3306/<instance>")
 var stmt = conn.createStatement(Jdbc.ResultSet.TYPE_FORWARD_ONLY,
                                 Jdbc.ResultSet.CONCUR_READ_ONLY);

 stmt.setMaxRows(100);
 var rs = stmt.execute("select * from person");

 while(rs.next()) {
   // Do something
 }

 rs.close();
 stmt.close();
 conn.close();

Parameters

NameTypeDescription
resultSetTypeIntegera result set type; one of Jdbc.ResultSet.TYPE_FORWARD_ONLY, Jdbc.ResultSet.TYPE_SCROLL_INSENSITIVE, or Jdbc.ResultSet.TYPE_SCROLL_SENSITIVE
resultSetConcurrencyIntegera concurrency type; one of Jdbc.ResultSet.CONCUR_READ_ONLY or Jdbc.ResultSet.CONCUR_UPDATABLE

Return

JdbcStatement — a JdbcStatement instance to execute queries with

See also


createStatement(resultSetType, resultSetConcurrency, resultSetHoldability)

Creates a JdbcStatement object for sending SQL statements to the database. This version allows the result set type, concurrency and holdability to be overridden.

 
// This sample code assumes authentication is off
 // For more information about this method, see documentation here:
 //  http://docs.oracle.com/javase/6/docs/api/java/sql/Connection.html#createStatement(int, int)
 var conn = Jdbc.getConnection("jdbc:mysql://<host>:3306/<instance>")
 var stmt = conn.createStatement(Jdbc.ResultSet.TYPE_FORWARD_ONLY,
                                 Jdbc.ResultSet.CONCUR_READ_ONLY,
                                 Jdbc.ResultSet.HOLD_CURSORS_OVER_COMMIT);

 stmt.setMaxRows(100);
 var rs = stmt.execute("select * from person");

 while(rs.next()) {
   // Do something
 }

 rs.close();
 stmt.close();
 conn.close();

Parameters

NameTypeDescription
resultSetTypeIntegera result set type; one of Jdbc.ResultSet.TYPE_FORWARD_ONLY, Jdbc.ResultSet.TYPE_SCROLL_INSENSITIVE, or Jdbc.ResultSet.TYPE_SCROLL_SENSITIVE
resultSetConcurrencyIntegera concurrency type; one of Jdbc.ResultSet.CONCUR_READ_ONLY or Jdbc.ResultSet.CONCUR_UPDATABLE
resultSetHoldabilityIntegera Jdbc.ResultSet holdability constant; one of Jdbc.ResultSet.HOLD_CURSORS_OVER_COMMIT or Jdbc.ResultSet.CLOSE_CURSORS_AT_COMMIT

Return

JdbcStatement — a JdbcStatement instance to execute queries with

See also


createStruct(typeName, attributes)

For documentation of this method, see java.sql.Connection#createStruct(String, Object[]).

Parameters

NameTypeDescription
typeNameString
attributesObject[]

Return

JdbcStruct


getAutoCommit()

For documentation of this method, see java.sql.Connection#getAutoCommit().

Return

Boolean


getCatalog()

For documentation of this method, see java.sql.Connection#getCatalog().

Return

String


getHoldability()

For documentation of this method, see java.sql.Connection#getHoldability().

Return

Integer


getMetaData()

For documentation of this method, see java.sql.Connection#getMetaData().

Return

JdbcDatabaseMetaData


getTransactionIsolation()

For documentation of this method, see java.sql.Connection#getTransactionIsolation().

Return

Integer


getWarnings()

For documentation of this method, see java.sql.Connection#getWarnings().

Return

String[]


isClosed()

For documentation of this method, see java.sql.Connection#isClosed().

Return

Boolean


isReadOnly()

For documentation of this method, see java.sql.Connection#isReadOnly().

Return

Boolean


isValid(timeout)

For documentation of this method, see java.sql.Connection#isValid(int).

Parameters

NameTypeDescription
timeoutInteger

Return

Boolean


nativeSQL(sql)

For documentation of this method, see java.sql.Connection#nativeSQL(String).

Parameters

NameTypeDescription
sqlString

Return

String


prepareCall(sql)

For documentation of this method, see java.sql.Connection#prepareCall(String).

Parameters

NameTypeDescription
sqlString

Return

JdbcCallableStatement


prepareCall(sql, resultSetType, resultSetConcurrency)

For documentation of this method, see java.sql.Connection#prepareCall(String, int, int).

Parameters

NameTypeDescription
sqlString
resultSetTypeInteger
resultSetConcurrencyInteger

Return

JdbcCallableStatement


prepareCall(sql, resultSetType, resultSetConcurrency, resultSetHoldability)

For documentation of this method, see java.sql.Connection#prepareCall(String, int, int, int).

Parameters

NameTypeDescription
sqlString
resultSetTypeInteger
resultSetConcurrencyInteger
resultSetHoldabilityInteger

Return

JdbcCallableStatement


prepareStatement(sql)

For documentation of this method, see java.sql.Connection#prepareStatement(String).

Parameters

NameTypeDescription
sqlString

Return

JdbcPreparedStatement


prepareStatement(sql, autoGeneratedKeys)

For documentation of this method, see java.sql.Connection#prepareStatement(String, int).

Parameters

NameTypeDescription
sqlString
autoGeneratedKeysInteger

Return

JdbcPreparedStatement


prepareStatement(sql, resultSetType, resultSetConcurrency)

For documentation of this method, see java.sql.Connection#prepareStatement(String, int, int).

Parameters

NameTypeDescription
sqlString
resultSetTypeInteger
resultSetConcurrencyInteger

Return

JdbcPreparedStatement


prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability)

For documentation of this method, see java.sql.Connection#prepareStatement(String, int, int, int).

Parameters

NameTypeDescription
sqlString
resultSetTypeInteger
resultSetConcurrencyInteger
resultSetHoldabilityInteger

Return

JdbcPreparedStatement


prepareStatementByIndex(sql, indices)

For documentation of this method, see java.sql.Connection#prepareStatement(String, int[]).

Parameters

NameTypeDescription
sqlString
indicesInteger[]

Return

JdbcPreparedStatement


prepareStatementByName(sql, columnNames)

For documentation of this method, see java.sql.Connection#prepareStatement(String, String[]).

Parameters

NameTypeDescription
sqlString
columnNamesString[]

Return

JdbcPreparedStatement


releaseSavepoint(savepoint)

For documentation of this method, see java.sql.Connection#releaseSavepoint(java.sql.Savepoint).

Parameters

NameTypeDescription
savepointJdbcSavepoint

rollback()

For documentation of this method, see java.sql.Connection#rollback().


rollback(savepoint)

For documentation of this method, see java.sql.Connection#rollback(java.sql.Savepoint).

Parameters

NameTypeDescription
savepointJdbcSavepoint

setAutoCommit(autoCommit)

For documentation of this method, see java.sql.Connection#setAutoCommit(boolean).

Parameters

NameTypeDescription
autoCommitBoolean

setCatalog(catalog)

For documentation of this method, see java.sql.Connection#setCatalog(String).

Parameters

NameTypeDescription
catalogString

setHoldability(holdability)

For documentation of this method, see java.sql.Connection#setHoldability(int).

Parameters

NameTypeDescription
holdabilityInteger

setReadOnly(readOnly)

For documentation of this method, see java.sql.Connection#setReadOnly(boolean).

Parameters

NameTypeDescription
readOnlyBoolean

setSavepoint()

For documentation of this method, see java.sql.Connection#setSavepoint().

Return

JdbcSavepoint


setSavepoint(name)

For documentation of this method, see java.sql.Connection#setSavepoint(String).

Parameters

NameTypeDescription
nameString

Return

JdbcSavepoint


setTransactionIsolation(level)

For documentation of this method, see java.sql.Connection#setTransactionIsolation(int).

Parameters

NameTypeDescription
levelInteger

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.