java.sql

Interface Connection

Known Subinterfaces:
ConnectionProxy
Known Implementing Classes:
DelegatingConnection, PoolableConnection, PoolingConnection

public interface Connection

A connection (session) with a specific database. SQL statements are executed and results are returned within the context of a connection.

A Connection object's database is able to provide information describing its tables, its supported SQL grammar, its stored procedures, the capabilities of this connection, and so on. This information is obtained with the getMetaData method.

Note: By default a Connection object is in auto-commit mode, which means that it automatically commits changes after executing each statement. If auto-commit mode has been disabled, the method commit must be called explicitly in order to commit changes; otherwise, database changes will not be saved.

A new Connection object created using the JDBC 2.1 core API has an initially empty type map associated with it. A user may enter a custom mapping for a UDT in this type map. When a UDT is retrieved from a data source with the method ResultSet.getObject, the getObject method will check the connection's type map to see if there is an entry for that UDT. If so, the getObject method will map the UDT to the class indicated. If there is no entry, the UDT will be mapped using the standard mapping.

A user may create a new type map, which is a java.util.Map object, make an entry in it, and pass it to the java.sql methods that can perform custom mapping. In this case, the method will use the given type map instead of the one associated with the connection.

For example, the following code fragment specifies that the SQL type ATHLETES will be mapped to the class Athletes in the Java programming language. The code fragment retrieves the type map for the Connection object con, inserts the entry into it, and then sets the type map with the new entry as the connection's type map.

      java.util.Map map = con.getTypeMap();
      map.put("mySchemaName.ATHLETES", Class.forName("Athletes"));
      con.setTypeMap(map);
 
See Also:
DriverManager.getConnection, Statement, ResultSet, DatabaseMetaData

Field Summary

static int
TRANSACTION_NONE
A constant indicating that transactions are not supported.
static int
TRANSACTION_READ_COMMITTED
A constant indicating that dirty reads are prevented; non-repeatable reads and phantom reads can occur.
static int
TRANSACTION_READ_UNCOMMITTED
A constant indicating that dirty reads, non-repeatable reads and phantom reads can occur.
static int
TRANSACTION_REPEATABLE_READ
A constant indicating that dirty reads and non-repeatable reads are prevented; phantom reads can occur.
static int
TRANSACTION_SERIALIZABLE
A constant indicating that dirty reads, non-repeatable reads and phantom reads are prevented.

Method Summary

void
clearWarnings()
Clears all warnings reported for this Connection object.
void
close()
Releases this Connection object's database and JDBC resources immediately instead of waiting for them to be automatically released.
void
commit()
Makes all changes made since the previous commit/rollback permanent and releases any database locks currently held by this Connection object.
Statement
createStatement()
Creates a Statement object for sending SQL statements to the database.
Statement
createStatement(int resultSetType, int resultSetConcurrency)
Creates a Statement object that will generate ResultSet objects with the given type and concurrency.
Statement
createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)
Creates a Statement object that will generate ResultSet objects with the given type, concurrency, and holdability.
boolean
getAutoCommit()
Retrieves the current auto-commit mode for this Connection object.
String
getCatalog()
Retrieves this Connection object's current catalog name.
int
getHoldability()
Retrieves the current holdability of ResultSet objects created using this Connection object.
DatabaseMetaData
getMetaData()
Retrieves a DatabaseMetaData object that contains metadata about the database to which this Connection object represents a connection.
int
getTransactionIsolation()
Retrieves this Connection object's current transaction isolation level.
java.util.Map>
getTypeMap()
Retrieves the Map object associated with this Connection object.
SQLWarning
getWarnings()
Retrieves the first warning reported by calls on this Connection object.
boolean
isClosed()
Retrieves whether this Connection object has been closed.
boolean
isReadOnly()
Retrieves whether this Connection object is in read-only mode.
String
nativeSQL(String sql)
Converts the given SQL statement into the system's native SQL grammar.
CallableStatement
prepareCall(String sql)
Creates a CallableStatement object for calling database stored procedures.
CallableStatement
prepareCall(String sql, int resultSetType, int resultSetConcurrency)
Creates a CallableStatement object that will generate ResultSet objects with the given type and concurrency.
CallableStatement
prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
Creates a CallableStatement object that will generate ResultSet objects with the given type and concurrency.
PreparedStatement
prepareStatement(String sql)
Creates a PreparedStatement object for sending parameterized SQL statements to the database.
PreparedStatement
prepareStatement(String sql, columnIndexes[] )
Creates a default PreparedStatement object capable of returning the auto-generated keys designated by the given array.
PreparedStatement
prepareStatement(String sql, columnNames[] )
Creates a default PreparedStatement object capable of returning the auto-generated keys designated by the given array.
PreparedStatement
prepareStatement(String sql, int autoGeneratedKeys)
Creates a default PreparedStatement object that has the capability to retrieve auto-generated keys.
PreparedStatement
prepareStatement(String sql, int resultSetType, int resultSetConcurrency)
Creates a PreparedStatement object that will generate ResultSet objects with the given type and concurrency.
PreparedStatement
prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
Creates a PreparedStatement object that will generate ResultSet objects with the given type, concurrency, and holdability.
void
releaseSavepoint(Savepoint savepoint)
Removes the given Savepoint object from the current transaction.
void
rollback()
Undoes all changes made in the current transaction and releases any database locks currently held by this Connection object.
void
rollback(Savepoint savepoint)
Undoes all changes made after the given Savepoint object was set.
void
setAutoCommit(boolean autoCommit)
Sets this connection's auto-commit mode to the given state.
void
setCatalog(String catalog)
Sets the given catalog name in order to select a subspace of this Connection object's database in which to work.
void
setHoldability(int holdability)
Changes the holdability of ResultSet objects created using this Connection object to the given holdability.
void
setReadOnly(boolean readOnly)
Puts this connection in read-only mode as a hint to the driver to enable database optimizations.
Savepoint
setSavepoint()
Creates an unnamed savepoint in the current transaction and returns the new Savepoint object that represents it.
Savepoint
setSavepoint(String name)
Creates a savepoint with the given name in the current transaction and returns the new Savepoint object that represents it.
void
setTransactionIsolation(int level)
Attempts to change the transaction isolation level for this Connection object to the one given.
void
setTypeMap(java.util.Map> map)
Installs the given TypeMap object as the type map for this Connection object.

Field Details

TRANSACTION_NONE

public static final int TRANSACTION_NONE
A constant indicating that transactions are not supported.
Field Value:
0
Usages and Demos :

View More Examples of Connection.TRANSACTION_NONE
   1:     switch(tx) {
   2:         case Connection.TRANSACTION_NONE :
   3:             txtxt = "TRANSACTION_NONE"; break;
   4:         case Connection.TRANSACTION_READ_COMMITTED :
   5:             txtxt = "TRANSACTION_READ_COMMITTED"; break;

View Full Code Here
   1:         return "TRANSACTION_REPEATABLE_READ";
   2:       case Connection.TRANSACTION_NONE:
   3:         return "TRANSACTION_NONE";
   4:     }
   5:     return "UNKNOWN";

View Full Code Here
   1:         switch(txisolation) {
   2:             case Connection.TRANSACTION_NONE: 
   3:                 return "TRANSACTION_NONE";
   4:             case Connection.TRANSACTION_READ_UNCOMMITTED: 
   5:                 return "TRANSACTION_NONE";

View Full Code Here
   1:       String value = "TRANSACTION_NONE";
   2:       int level = Connection.TRANSACTION_NONE;
   3:       System.out.println(s + value + "=[" 
   4:         ...
   5:       System.out.println("Default database isolation level is " + dbLevel);
   6:       System.out.println(Connection.TRANSACTION_NONE 
   7:                          + " is TRANSACTION_NONE");
   8:       System.out.println(Connection.TRANSACTION_READ_UNCOMMITTED 
   9:                          + " is TRANSACTION_READ_UNCOMMITTED");

View Full Code Here
   1:         switch(txisolation) {
   2:             case Connection.TRANSACTION_NONE: 
   3:                 return "TRANSACTION_NONE";
   4:             case Connection.TRANSACTION_READ_UNCOMMITTED: 
   5:                 return "TRANSACTION_NONE";

View Full Code Here

TRANSACTION_READ_COMMITTED

public static final int TRANSACTION_READ_COMMITTED
A constant indicating that dirty reads are prevented; non-repeatable reads and phantom reads can occur. This level only prohibits a transaction from reading a row with uncommitted changes in it.
Field Value:
2
Usages and Demos :

View More Examples of Connection.TRANSACTION_READ_COMMITTED
   1:             txtxt = "TRANSACTION_NONE"; break;
   2:         case Connection.TRANSACTION_READ_COMMITTED :
   3:             txtxt = "TRANSACTION_READ_COMMITTED"; break;
   4:         case Connection.TRANSACTION_READ_UNCOMMITTED :
   5:             txtxt = "TRANSACTION_READ_UNCOMMITTED"; break;

View Full Code Here
   1:                 connection.setTransactionIsolation(
   2:                     Connection.TRANSACTION_READ_COMMITTED);
   3:             } catch (NamingException ex) {
   4:                 throw new DBException("Cannot find JDBC Data Source with JNDI name " + 
   5:                         DBConfiguration.getDSName(),ex);

View Full Code Here
   1:     {
   2:       case Connection.TRANSACTION_READ_COMMITTED:
   3:         return "READ_COMMITTED";
   4:       case Connection.TRANSACTION_SERIALIZABLE:
   5:         return "TRANSACTION_SERIALIZABLE";

View Full Code Here
   1:                 return "TRANSACTION_NONE";
   2:             case Connection.TRANSACTION_READ_COMMITTED: 
   3:                 return "TRANSACTION_READ_COMMITTED";
   4:             case Connection.TRANSACTION_REPEATABLE_READ: 
   5:                 return "TRANSACTION_REPEATABLE_READ";

View Full Code Here
   1:                 return "TRANSACTION_NONE";
   2:             case Connection.TRANSACTION_READ_COMMITTED: 
   3:                 return "TRANSACTION_READ_COMMITTED";
   4:             case Connection.TRANSACTION_REPEATABLE_READ: 
   5:                 return "TRANSACTION_REPEATABLE_READ";

View Full Code Here

TRANSACTION_READ_UNCOMMITTED

public static final int TRANSACTION_READ_UNCOMMITTED
A constant indicating that dirty reads, non-repeatable reads and phantom reads can occur. This level allows a row changed by one transaction to be read by another transaction before any changes in that row have been committed (a "dirty read"). If any of the changes are rolled back, the second transaction will have retrieved an invalid row.
Field Value:
1
Usages and Demos :

View More Examples of Connection.TRANSACTION_READ_UNCOMMITTED
   1:             txtxt = "TRANSACTION_READ_COMMITTED"; break;
   2:         case Connection.TRANSACTION_READ_UNCOMMITTED :
   3:             txtxt = "TRANSACTION_READ_UNCOMMITTED"; break;
   4:         case Connection.TRANSACTION_REPEATABLE_READ :
   5:             txtxt = "TRANSACTION_REPEATABLE_READ"; break;

View Full Code Here
   1:         return "TRANSACTION_SERIALIZABLE";
   2:       case Connection.TRANSACTION_READ_UNCOMMITTED:
   3:         return "TRANSACTION_READ_UNCOMMITTED";
   4:       case Connection.TRANSACTION_REPEATABLE_READ:
   5:         return "TRANSACTION_REPEATABLE_READ";

View Full Code Here
   1:                 return "TRANSACTION_NONE";
   2:             case Connection.TRANSACTION_READ_UNCOMMITTED: 
   3:                 return "TRANSACTION_NONE";
   4:             case Connection.TRANSACTION_READ_COMMITTED: 
   5:                 return "TRANSACTION_READ_COMMITTED";

View Full Code Here
   1:       value = "TRANSACTION_READ_UNCOMMITTED";
   2:       level = Connection.TRANSACTION_READ_UNCOMMITTED;
   3:       System.out.println(s + value + "=[" 
   4:         ...
   5:                          + " is TRANSACTION_NONE");
   6:       System.out.println(Connection.TRANSACTION_READ_UNCOMMITTED 
   7:                          + " is TRANSACTION_READ_UNCOMMITTED");
   8:       System.out.println(Connection.TRANSACTION_READ_COMMITTED 
   9:                          + " is TRANSACTION_READ_COMMITTED");

View Full Code Here
   1:                 return "TRANSACTION_NONE";
   2:             case Connection.TRANSACTION_READ_UNCOMMITTED: 
   3:                 return "TRANSACTION_NONE";
   4:             case Connection.TRANSACTION_READ_COMMITTED: 
   5:                 return "TRANSACTION_READ_COMMITTED";

View Full Code Here

TRANSACTION_REPEATABLE_READ

public static final int TRANSACTION_REPEATABLE_READ
A constant indicating that dirty reads and non-repeatable reads are prevented; phantom reads can occur. This level prohibits a transaction from reading a row with uncommitted changes in it, and it also prohibits the situation where one transaction reads a row, a second transaction alters the row, and the first transaction rereads the row, getting different values the second time (a "non-repeatable read").
Field Value:
4
Usages and Demos :

View More Examples of Connection.TRANSACTION_REPEATABLE_READ
   1:             txtxt = "TRANSACTION_READ_UNCOMMITTED"; break;
   2:         case Connection.TRANSACTION_REPEATABLE_READ :
   3:             txtxt = "TRANSACTION_REPEATABLE_READ"; break;
   4:         ...
   5:     System.out.println("Done");
   6:     con.setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ);
   7:     System.out.println("TX is now " + con.getTransactionIsolation());
   8:     }
   9: }

View Full Code Here
   1:         return "TRANSACTION_READ_UNCOMMITTED";
   2:       case Connection.TRANSACTION_REPEATABLE_READ:
   3:         return "TRANSACTION_REPEATABLE_READ";
   4:       case Connection.TRANSACTION_NONE:
   5:         return "TRANSACTION_NONE";

View Full Code Here
   1:                 return "TRANSACTION_READ_COMMITTED";
   2:             case Connection.TRANSACTION_REPEATABLE_READ: 
   3:                 return "TRANSACTION_REPEATABLE_READ";
   4:             case Connection.TRANSACTION_SERIALIZABLE:
   5:                 return "TRANSACTION_SERIALIZABLE";

View Full Code Here
   1:       value = "TRANSACTION_REPEATABLE_READ";
   2:       level = Connection.TRANSACTION_REPEATABLE_READ;
   3:       System.out.println(s + value + "=[" 
   4:         ...
   5:                          + " is TRANSACTION_READ_COMMITTED");
   6:       System.out.println(Connection.TRANSACTION_REPEATABLE_READ 
   7:                          + " is TRANSACTION_REPEATABLE_READ");
   8:       System.out.println(Connection.TRANSACTION_SERIALIZABLE 
   9:                          + " is TRANSACTION_SERIALIZABLE");

View Full Code Here
   1:                 return "TRANSACTION_READ_COMMITTED";
   2:             case Connection.TRANSACTION_REPEATABLE_READ: 
   3:                 return "TRANSACTION_REPEATABLE_READ";
   4:             case Connection.TRANSACTION_SERIALIZABLE:
   5:                 return "TRANSACTION_SERIALIZABLE";

View Full Code Here

TRANSACTION_SERIALIZABLE

public static final int TRANSACTION_SERIALIZABLE
A constant indicating that dirty reads, non-repeatable reads and phantom reads are prevented. This level includes the prohibitions in TRANSACTION_REPEATABLE_READ and further prohibits the situation where one transaction reads all rows that satisfy a WHERE condition, a second transaction inserts a row that satisfies that WHERE condition, and the first transaction rereads for the same condition, retrieving the additional "phantom" row in the second read.
Field Value:
8
Usages and Demos :

View More Examples of Connection.TRANSACTION_SERIALIZABLE
   1:             txtxt = "TRANSACTION_REPEATABLE_READ"; break;
   2:         case Connection.TRANSACTION_SERIALIZABLE :
   3:             txtxt = "TRANSACTION_SERIALIZABLE"; break;
   4:         default:
   5:             txtxt = "UNKNOWN!!";

View Full Code Here
   1:         _getTransactionIsolationDesc( txnIsolationLevel ) );
   2:       conn.setTransactionIsolation( Connection.TRANSACTION_SERIALIZABLE );
   3:       txnIsolationLevel = conn.getTransactionIsolation();
   4:         ...
   5:         return "READ_COMMITTED";
   6:       case Connection.TRANSACTION_SERIALIZABLE:
   7:         return "TRANSACTION_SERIALIZABLE";
   8:       case Connection.TRANSACTION_READ_UNCOMMITTED:
   9:         return "TRANSACTION_READ_UNCOMMITTED";

View Full Code Here
   1:                 return "TRANSACTION_REPEATABLE_READ";
   2:             case Connection.TRANSACTION_SERIALIZABLE:
   3:                 return "TRANSACTION_SERIALIZABLE";
   4:             default:
   5:                 throw new IllegalArgumentException(

View Full Code Here
   1:       value = "TRANSACTION_SERIALIZABLE";
   2:       level = Connection.TRANSACTION_SERIALIZABLE;
   3:       System.out.println(s + value + "=[" 
   4:         ...
   5:                          + " is TRANSACTION_REPEATABLE_READ");
   6:       System.out.println(Connection.TRANSACTION_SERIALIZABLE 
   7:                          + " is TRANSACTION_SERIALIZABLE");
   8: 
   9:     } catch (Exception e) {

View Full Code Here
   1:                 return "TRANSACTION_REPEATABLE_READ";
   2:             case Connection.TRANSACTION_SERIALIZABLE:
   3:                 return "TRANSACTION_SERIALIZABLE";
   4:             default:
   5:                 throw new IllegalArgumentException(

View Full Code Here

Method Details

clearWarnings

public void clearWarnings()
            throws SQLException
Clears all warnings reported for this Connection object. After a call to this method, the method getWarnings returns null until a new warning is reported for this Connection object.
Throws:
SQLException - if a database access error occurs
Usages and Demos :

View More Examples of clearWarnings()
   1: 
   2: import java.sql.Connection;
   3: import java.sql.SQLException;
   4:         ...
   5: 
   6:     public static void logAndClearWarnings(Connection con) throws SQLException
   7:     {
   8:         ...
   9:         }
  10:         con.clearWarnings();
  11:     }

View Full Code Here
   1: 
   2: import java.sql.Connection;
   3: import java.sql.SQLException;
   4:         ...
   5:     
   6:     public static void logAndClearWarnings(Connection connection) {
   7:         if ( log.isWarnEnabled() ) {
   8:         ...
   9:                 logWarnings( connection.getWarnings() );
  10:                 connection.clearWarnings();
  11:             }

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: class C3P0Connection implements Connection
   7: {
   8:         ...
   9:     final Connection inner;
  10: 
  11:         ...
  12:     {
  13:         inner.clearWarnings();

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: public abstract class FilterConnection implements Connection
   7: {
   8:         ...
   9:     protected Connection inner;
  10:     
  11:         ...
  12:     public void clearWarnings() throws SQLException
  13:     { inner.clearWarnings(); }

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: public abstract class SynchronizedFilterConnection implements Connection
   7: {
   8:         ...
   9:     protected Connection inner;
  10:     
  11:         ...
  12:     public synchronized void clearWarnings() throws SQLException
  13:     { inner.clearWarnings(); }

View Full Code Here

close

public void close()
            throws SQLException
Releases this Connection object's database and JDBC resources immediately instead of waiting for them to be automatically released.

Calling the method close on a Connection object that is already closed is a no-op.

Note: A Connection object is automatically closed when it is garbage collected. Certain fatal errors also close a Connection object.

Throws:
SQLException - if a database access error occurs
Usages and Demos :

View More Examples of close()
   1: import ConnectionFactory;
   2: import java.sql.Connection;
   3: public class TestSystemResource {
   4:         ...
   5:   public static void main(String[] a) throws Throwable {
   6:     Connection cn = ConnectionFactory.getConnection("default");
   7:         ...
   8:     cn.close();
   9:   }

View Full Code Here
   1: 
   2:   protected Connection myConn;
   3:   
   4:         ...
   5:   {
   6:    myConn.close();
   7:   }
   8:   
   9: }

View Full Code Here
   1: import java.io.Reader;
   2: import java.sql.Connection;
   3: 
   4:         ...
   5:   public static void main(String[] args) throws Exception {
   6:     Connection conn = Examples.getConnection();
   7:     Reader r = XMLDocuments.getReader(conn,"/plays/shakespeare/dream.xml");
   8:       XMLHelper.parse(r,null);
   9:     }

View Full Code Here
   1:       Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
   2:       Connection c = DriverManager.getConnection("jdbc:odbc:Kurse");
   3:       Statement s = c.createStatement();
   4:         ...
   5:         System.out.println(r.getString("vorname")+" "+r.getString("nachname"));
   6:       c.close();
   7:     }
   8:   }   

View Full Code Here
   1: 
   2:         Connection conn = ds.getConnection("student", "student");
   3:         ...
   4:         System.out.println("Connection = " + conn);
   5:         ...
   6:         conn.close();
   7:     }

View Full Code Here

commit

public void commit()
            throws SQLException
Makes all changes made since the previous commit/rollback permanent and releases any database locks currently held by this Connection object. This method should be used only when auto-commit mode has been disabled.
Throws:
SQLException - if a database access error occurs or this Connection object is in auto-commit mode
Usages and Demos :

View More Examples of commit()
   1: 
   2: import java.sql.Connection;
   3: 
   4:         ...
   5:     public void testWithUnrelatedInterfaces() throws Exception {
   6:         Object obj = NullProxy.create(new Class[]{UnitOfWork.class, Connection.class});
   7:         assertNotNull(obj);
   8:         ...
   9:         uow.flush(null);
  10:         Connection con = (Connection) obj;
  11:         ...
  12:         con.commit();

View Full Code Here
   1:   public static void main(String args[])throws Exception{
   2:     Connection con=new ConnectionProvider().getConnection();
   3:     try{
   4:         ...
   5:         +"values(2,'Jack',1000)");
   6:       con.commit();
   7:     }catch(SQLException e){
   8:     }finally{
   9:       con.close();

View Full Code Here
   1:     Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); 
   2:     Connection c = DriverManager.getConnection("jdbc:odbc:Kurse");
   3:     DatabaseMetaData dbmd = c.getMetaData();
   4:         ...
   5:     s.execute("INSERT INTO Teilnehmer(pcode,kcode) VALUES (444,444)");
   6:     c.commit();
   7:     s.execute("INSERT INTO Teilnehmer(pcode,kcode) VALUES (555,555)");
   8:     c.rollback();    s.execute("INSERT INTO Teilnehmer(pcode,kcode) VALUES (666,666)");
   9:     s.execute("INSERT INTO Teilnehmer(pcode,kcode) VALUES (777,777)");

View Full Code Here
   1: 
   2:       con.commit();
   3:     }
   4:         ...
   5: 
   6:   private Connection establishConnection() throws SQLException {
   7:   }
   8: }

View Full Code Here
   1: 
   2:     Connection con = null;
   3:     try {
   4:         ...
   5: 
   6:       con.commit();
   7:       out.println("Order successful!  Thanks for your business!");
   8:     }
   9:     catch (Exception e) {

View Full Code Here

createStatement

public Statement createStatement()
            throws SQLException
Creates a Statement object for sending SQL statements to the database. SQL statements without parameters are normally executed using Statement objects. If the same SQL statement is executed many times, it may be more efficient to use a PreparedStatement object.

Result sets created using the returned Statement object will by default be type TYPE_FORWARD_ONLY and have a concurrency level of CONCUR_READ_ONLY.

Returns:
a new default Statement object
Throws:
SQLException - if a database access error occurs
Usages and Demos :

View More Examples of createStatement()
   1:         try {
   2:             c.createStatement().execute("SHUTDOWN");
   3:         } catch (SQLException sqe) {
   4:             System.err.println(sqe.getMessage());
   5:         }

View Full Code Here
   1: 
   2: import java.sql.Connection;
   3: import java.sql.DriverManager;
   4:         ...
   5:         
   6:         Connection reconnectableConn = DriverManager.getConnection(BaseTestCase.dbUrl + sepChar + "autoReconnect=true", props);
   7:         
   8:         ...
   9:         rs = reconnectableConn.createStatement().executeQuery("SELECT CONNECTION_ID()");
  10:         rs.next();
  11:         ...
  12: 
  13:         System.out.println("You have 30 seconds to kill connection id " + connectionId + "...");

View Full Code Here
   1: 
   2: import java.sql.Connection;
   3: import java.sql.SQLException;
   4:         ...
   5:      
   6:       Connection conn=null; 
   7:       
   8:         ...
   9:          conn=DatabaseConnectionFactory.getConnection();
  10:          conn.createStatement().execute("DELETE FROM PROFILES WHERE PROFILE_ID="+profile_id);
  11:         ...
  12:          conn.createStatement().execute("DELETE FROM PROFILE_NODES WHERE PROFILE_ID="+profile_id);

View Full Code Here
   1: import java.sql.DriverManager;
   2: import java.sql.Connection;
   3: import java.io.*;
   4:         ...
   5:     String[] split=null;
   6:     Connection connection=null;
   7:     List errors=new ArrayList();
   8:         ...
   9:                     connection = DriverManager.getConnection(form.getDatabase_url(), form.getDatabase_user(), form.getDatabase_password() );
  10:                     connection.createStatement().execute("create database " + form.getDatabase_name());
  11:                     }

View Full Code Here
   1: 
   2: import java.sql.Connection;
   3: import java.sql.DriverManager;
   4:         ...
   5:         {
   6:             Connection connection = DriverManager.getConnection(url);
   7:         ...
   8:             connection.createStatement().execute(TestConstants.HYPERSONIC_TEST_SQL);
   9:             connection.close();
  10:         ...
  11:             Connection connection = DriverManager.getConnection(url);
  12:             connection.createStatement().execute(TestConstants.HYPERSONIC_TEST_SQL);

View Full Code Here

createStatement

public Statement createStatement(int resultSetType,
                                 int resultSetConcurrency)
            throws SQLException
Creates a Statement object that will generate ResultSet objects with the given type and concurrency. This method is the same as the createStatement method above, but it allows the default result set type and concurrency to be overridden.
Parameters:
resultSetType - a result set type; one of ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE, or ResultSet.TYPE_SCROLL_SENSITIVE
resultSetConcurrency - a concurrency type; one of ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE
Returns:
a new Statement object that will generate ResultSet objects with the given type and concurrency
Throws:
SQLException - if a database access error occurs or the given parameters are not ResultSet constants indicating type and concurrency
Since:
1.2
Usages and Demos :

View More Examples of createStatement(int resultSetType,int resultSetConcurrency)
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: class C3P0Connection implements Connection
   7: {
   8:         ...
   9:     final Connection inner;
  10: 
  11:         ...
  12:     {
  13:         return inner.createStatement(a, b);

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: public abstract class FilterConnection implements Connection
   7: {
   8:         ...
   9:     protected Connection inner;
  10:     
  11:         ...
  12:     public Statement createStatement(int a, int b) throws SQLException
  13:     { return inner.createStatement(a, b); }

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: public abstract class SynchronizedFilterConnection implements Connection
   7: {
   8:         ...
   9:     protected Connection inner;
  10:     
  11:         ...
  12:     public synchronized Statement createStatement(int a, int b) throws SQLException
  13:     { return inner.createStatement(a, b); }

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: class PooledConnection implements Connection {
   7:         ...
   8:     Connection con = null;
   9:     ConnectionPool pool = null;
  10:         ...
  11:             throws SQLException {
  12:         return con.createStatement(resultSetType, resultSetConcurrency);

View Full Code Here
   1: 
   2: public class ConnectionAdapter implements Connection {
   3: 
   4:         ...
   5:     protected Connection connection;
   6: 
   7:         ...
   8:     {
   9:         return connection.createStatement(resultSetType, resultSetConcurrency);
  10:     }

View Full Code Here

createStatement

public Statement createStatement(int resultSetType,
                                 int resultSetConcurrency,
                                 int resultSetHoldability)
            throws SQLException
Creates a Statement object that will generate ResultSet objects with the given type, concurrency, and holdability. This method is the same as the createStatement method above, but it allows the default result set type, concurrency, and holdability to be overridden.
Parameters:
resultSetType - one of the following ResultSet constants: ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE, or ResultSet.TYPE_SCROLL_SENSITIVE
resultSetConcurrency - one of the following ResultSet constants: ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE
resultSetHoldability - one of the following ResultSet constants: ResultSet.HOLD_CURSORS_OVER_COMMIT or ResultSet.CLOSE_CURSORS_AT_COMMIT
Returns:
a new Statement object that will generate ResultSet objects with the given type, concurrency, and holdability
Throws:
SQLException - if a database access error occurs or the given parameters are not ResultSet constants indicating type, concurrency, and holdability
Since:
1.4
See Also:
ResultSet
Usages and Demos :

View More Examples of createStatement(int resultSetType,int resultSetConcurrency,int resultSetHoldability)
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: public abstract class FilterConnection implements Connection
   7: {
   8:         ...
   9:     protected Connection inner;
  10:     
  11:         ...
  12:     public Statement createStatement(int a, int b, int c) throws SQLException
  13:     { return inner.createStatement(a, b, c); }

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: public abstract class SynchronizedFilterConnection implements Connection
   7: {
   8:         ...
   9:     protected Connection inner;
  10:     
  11:         ...
  12:     public synchronized Statement createStatement(int a, int b, int c) throws SQLException
  13:     { return inner.createStatement(a, b, c); }

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: class PooledConnection implements Connection {
   7:         ...
   8:     Connection con = null;
   9:     ConnectionPool pool = null;
  10:         ...
  11:                                      int resultSetHoldability) throws SQLException {
  12:         return con.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability);

View Full Code Here
   1: public class TraceConnection
   2:         implements Connection
   3: {
   4:         ...
   5:     protected Connection conn;
   6:     
   7:         ...
   8:     public TraceConnection(Connection co) 
   9:     {
  10:         ...
  11:     {
  12:         Statement stm = conn.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability);

View Full Code Here
   1: 
   2: public class ConnectionAdapter implements Connection {
   3: 
   4:         ...
   5:     protected Connection connection;
   6: 
   7:         ...
   8:                           throws SQLException{
   9:                 return connection.createStatement(resultSetType,resultSetConcurrency,resultSetHoldability);
  10:                           }

View Full Code Here

getAutoCommit

public boolean getAutoCommit()
            throws SQLException
Retrieves the current auto-commit mode for this Connection object.
Returns:
the current state of this Connection object's auto-commit mode
Throws:
SQLException - if a database access error occurs
Usages and Demos :

View More Examples of getAutoCommit()
   1:         }
   2:         Connection conn = null;
   3:         Statement stmt = null;
   4:         ...
   5:             conn = dl.getConnection();
   6:             oldCommit = conn.getAutoCommit();
   7:             conn.setAutoCommit(false);
   8:             stmt = conn.createStatement();
   9:             stmt.executeUpdate("DELETE FROM cmf_object_locks " +

View Full Code Here
   1:         }
   2:         Connection conn = null;
   3:         Statement stmt = null;
   4:         ...
   5:             conn = dl.getConnection();
   6:             oldCommit = conn.getAutoCommit();
   7:             conn.setAutoCommit(false);
   8:             stmtUp = conn.createStatement();
   9:             stmt = conn.createStatement();

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: class C3P0Connection implements Connection
   7: {
   8:         ...
   9:     final Connection inner;
  10: 
  11:         ...
  12:     {
  13:         return inner.getAutoCommit();

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: public abstract class FilterConnection implements Connection
   7: {
   8:         ...
   9:     protected Connection inner;
  10:     
  11:         ...
  12:     public boolean getAutoCommit() throws SQLException
  13:     { return inner.getAutoCommit(); }

View Full Code Here
   1: 
   2: import java.sql.Connection;
   3: import java.sql.Statement;
   4:         ...
   5:     {
   6:         Connection conn = null;
   7:         boolean oldCommit = false;
   8:         ...
   9:             conn = dl.getConnection();
  10:             oldCommit = conn.getAutoCommit();
  11:             conn.setAutoCommit(false);
  12:         ...
  13:     {
  14:         Connection conn = null;

View Full Code Here

getCatalog

public String getCatalog()
            throws SQLException
Retrieves this Connection object's current catalog name.
Returns:
the current catalog name or null if there is none
Throws:
SQLException - if a database access error occurs
Usages and Demos :

View More Examples of getCatalog()
   1: 
   2:     public static Connection getConnection() throws Exception {
   3: 
   4:         ...
   5:         String password = "root";
   6:         Connection conn = DriverManager.getConnection(url, username, password);
   7:         return conn;
   8:         ...
   9: 
  10:         Connection conn = null;
  11:         try {

View Full Code Here
   1: 
   2:     public static Connection getConnection() throws Exception {
   3:         String driver = "oracle.jdbc.driver.OracleDriver";
   4:         ...
   5:     public static void main(String[] args) {
   6:         Connection conn = null;
   7:         Statement stmt = null;
   8:         ResultSet rs = null;
   9:         try {

View Full Code Here
   1:         String password = "root";
   2:         Connection conn = null;
   3: 
   4:         ...
   5: 
   6:               System.out.println("conn.getCatalog()="+conn.getCatalog());
   7: 
   8:         ...
   9:                                  (conn,
  10:                                   conn.getCatalog(),
  11:                                   null,
  12:         ...
  13:                                  (conn,
  14:                                   conn.getCatalog(),

View Full Code Here
   1:         String driver = "oracle.jdbc.driver.OracleDriver";
   2:         Connection conn = null;
   3: 
   4:         try {
   5:               Class.forName(driver);

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: class C3P0Connection implements Connection
   7: {
   8:         ...
   9:     final Connection inner;
  10: 
  11:         ...
  12:     {
  13:         return inner.getCatalog();

View Full Code Here

getHoldability

public int getHoldability()
            throws SQLException
Retrieves the current holdability of ResultSet objects created using this Connection object.
Returns:
the holdability, one of ResultSet.HOLD_CURSORS_OVER_COMMIT or ResultSet.CLOSE_CURSORS_AT_COMMIT
Throws:
SQLException - if a database access occurs
Since:
1.4
Usages and Demos :

View More Examples of getHoldability()
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: public abstract class FilterConnection implements Connection
   7: {
   8:         ...
   9:     protected Connection inner;
  10:     
  11:         ...
  12:     public int getHoldability() throws SQLException
  13:     { return inner.getHoldability(); }

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: public abstract class SynchronizedFilterConnection implements Connection
   7: {
   8:         ...
   9:     protected Connection inner;
  10:     
  11:         ...
  12:     public synchronized int getHoldability() throws SQLException
  13:     { return inner.getHoldability(); }

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: class PooledConnection implements Connection {
   7:         ...
   8:     Connection con = null;
   9:     ConnectionPool pool = null;
  10:         ...
  11:     public int getHoldability() throws SQLException {
  12:         return con.getHoldability();

View Full Code Here
   1: public class TraceConnection
   2:         implements Connection
   3: {
   4:         ...
   5:     protected Connection conn;
   6:     
   7:         ...
   8:     public TraceConnection(Connection co) 
   9:     {
  10:         ...
  11:     public void setHoldability(int holdability) throws SQLException { conn.setHoldability(holdability);   }
  12:     public int getHoldability() throws SQLException { return conn.getHoldability(); }

View Full Code Here
   1: 
   2: public class ConnectionAdapter implements Connection {
   3: 
   4:         ...
   5:     protected Connection connection;
   6: 
   7:         ...
   8:     public int getHoldability() throws SQLException{
   9:         return connection.getHoldability();
  10:     }

View Full Code Here

getMetaData

public DatabaseMetaData getMetaData()
            throws SQLException
Retrieves a DatabaseMetaData object that contains metadata about the database to which this Connection object represents a connection. The metadata includes information about the database's tables, its supported SQL grammar, its stored procedures, the capabilities of this connection, and so on.
Returns:
a DatabaseMetaData object for this Connection object
Throws:
SQLException - if a database access error occurs
Usages and Demos :

View More Examples of getMetaData()
   1:     Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); 
   2:     Connection c = 
   3:       DriverManager.getConnection("jdbc:odbc:Kurse");
   4:         ...
   5:       DatabaseMetaData meta = c.getMetaData();
   6:       System.out.println(meta.getDatabaseProductName() + " " 
   7:                        + meta.getDatabaseProductVersion() );
   8:       System.out.println("Supports UNION: " + meta.supportsUnion());

View Full Code Here
   1:     Class.forName("oracle.jdbc.driver.OracleDriver"); 
   2:     Connection c = DriverManager.getConnection(
   3:                     "jdbc:oracle:thin:@p30:1521:jdbcbuch", "system","manager");
   4:         ...
   5:     DatabaseMetaData meta = c.getMetaData();
   6:     System.out.println(meta.getDatabaseProductName() + " " 
   7:                                        + meta.getDatabaseProductVersion() );
   8:     System.out.println("Entry Level  " + meta.supportsANSI92EntryLevelSQL());

View Full Code Here
   1:     Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); 
   2:     Connection c = DriverManager.getConnection("jdbc:odbc:Kurse");
   3:         ...
   4:     DatabaseMetaData meta = c.getMetaData();
   5:     System.out.println(meta.getDatabaseProductName() + " " +
   6:                                          meta.getDatabaseProductVersion());
   7:     System.out.println("Entry Level  " + meta.supportsANSI92EntryLevelSQL());

View Full Code Here
   1:     Class.forName("oracle.jdbc.driver.OracleDriver");
   2:     Connection c = DriverManager.getConnection(
   3:             "jdbc:oracle:thin:@p30:1521:jdbcbuch", "system", "manager");
   4:         ...
   5:     DatabaseMetaData meta = c.getMetaData();
   6:     System.out.println(meta.getDatabaseProductName() + " " +
   7:                        meta.getDatabaseProductVersion() );
   8:     System.out.println("Stored Procedures: " + meta.supportsStoredProcedures() );

View Full Code Here
   1:   public static void main(String[] args)throws SQLException{  
   2:     Connection con=new ConnectionProvider().getConnection();
   3:         ...
   4:     DatabaseMetaData metaData=con.getMetaData();
   5:     System.out.println("????????l?????:"+metaData.getMaxConnections());
   6:     System.out.println("???l???????????Statement?????????:"+metaData.getMaxStatements());
   7:   

View Full Code Here

getTransactionIsolation

public int getTransactionIsolation()
            throws SQLException
Retrieves this Connection object's current transaction isolation level.
Returns:
the current transaction isolation level, which will be one of the following constants: Connection.TRANSACTION_READ_UNCOMMITTED, Connection.TRANSACTION_READ_COMMITTED, Connection.TRANSACTION_REPEATABLE_READ, Connection.TRANSACTION_SERIALIZABLE, or Connection.TRANSACTION_NONE.
Throws:
SQLException - if a database access error occurs
Usages and Demos :

View More Examples of getTransactionIsolation()
   1:     Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
   2:     Connection con = DriverManager.getConnection(
   3:         "jdbc:odbc:MusicVideo");
   4:         ...
   5:     switch(tx) {
   6:         case Connection.TRANSACTION_NONE :
   7:             txtxt = "TRANSACTION_NONE"; break;
   8:         ...
   9:         case Connection.TRANSACTION_READ_COMMITTED :
  10:             txtxt = "TRANSACTION_READ_COMMITTED"; break;
  11:         ...
  12:     con.setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ);
  13:     System.out.println("TX is now " + con.getTransactionIsolation());

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: class C3P0Connection implements Connection
   7: {
   8:         ...
   9:     final Connection inner;
  10: 
  11:         ...
  12:     {
  13:         return inner.getTransactionIsolation();

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: public abstract class FilterConnection implements Connection
   7: {
   8:         ...
   9:     protected Connection inner;
  10:     
  11:         ...
  12:     public int getTransactionIsolation() throws SQLException
  13:     { return inner.getTransactionIsolation(); }

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: public abstract class SynchronizedFilterConnection implements Connection
   7: {
   8:         ...
   9:     protected Connection inner;
  10:     
  11:         ...
  12:     public synchronized int getTransactionIsolation() throws SQLException
  13:     { return inner.getTransactionIsolation(); }

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: class PooledConnection implements Connection {
   7:         ...
   8:     Connection con = null;
   9:     ConnectionPool pool = null;
  10:         ...
  11:     public int getTransactionIsolation() throws SQLException {
  12:         return con.getTransactionIsolation();

View Full Code Here

getTypeMap

public java.util.Map> getTypeMap()
            throws SQLException
Retrieves the Map object associated with this Connection object. Unless the application has added an entry, the type map returned will be empty.
Returns:
the java.util.Map object associated with this Connection object
Throws:
SQLException - if a database access error occurs
Since:
1.2
Usages and Demos :

View More Examples of getTypeMap()
   1:   public static void main(String[] args) {
   2:     Connection connection = null;
   3:     PreparedStatement ps = null;
   4:         ...
   5:     try {
   6:       connection = ConnectionFactory.getConnection();
   7:         ...
   8:       Map map = connection.getTypeMap();
   9:       map.put("ARTIST", Artist.class);

View Full Code Here
   1:  public class InsertCustomType2_Oracle {
   2:    public static Connection getConnection() throws Exception {
   3:       String driver = "oracle.jdbc.driver.OracleDriver";
   4:         ...
   5: 
   6:       Connection conn = null;
   7:       PreparedStatement pstmt = null;
   8:         ...
   9:          conn = getConnection();
  10:          java.util.Map map = conn.getTypeMap();
  11:          System.out.println("map="+map);

View Full Code Here
   1: import java.sql.SQLException;
   2: import java.sql.Connection;
   3: import java.sql.PreparedStatement;
   4:         ...
   5:   {  
   6:     Connection connection = null;
   7:     ResultSet rset = null;
   8:         ...
   9:         "benchmark", "benchmark", "ora10g" );
  10:       Map myMap = connection.getTypeMap();
  11:       myMap.put ( "BENCHMARK.ADDRESS", 

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: class C3P0Connection implements Connection
   7: {
   8:         ...
   9:     final Connection inner;
  10: 
  11:         ...
  12:     {
  13:         return inner.getTypeMap();

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: public abstract class FilterConnection implements Connection
   7: {
   8:         ...
   9:     protected Connection inner;
  10:     
  11:         ...
  12:     public Map getTypeMap() throws SQLException
  13:     { return inner.getTypeMap(); }

View Full Code Here

getWarnings

public SQLWarning getWarnings()
            throws SQLException
Retrieves the first warning reported by calls on this Connection object. If there is more than one warning, subsequent warnings will be chained to the first one and can be retrieved by calling the method SQLWarning.getNextWarning on the warning that was retrieved previously.

This method may not be called on a closed connection; doing so will cause an SQLException to be thrown.

Note: Subsequent warnings will be chained to this SQLWarning.

Returns:
the first SQLWarning object or null if there are none
Throws:
SQLException - if a database access error occurs or this method is called on a closed connection
See Also:
SQLWarning
Usages and Demos :

View More Examples of getWarnings()
   1: 
   2:          System.out.println("Getting Connection");
   3:         ...
   4:          Connection conn =
   5: 
   6:         ...
   7: 
   8:          SQLWarning warn = conn.getWarnings();
   9:          while (warn != null) {

View Full Code Here
   1: 
   2: import java.sql.Connection;
   3: import java.sql.SQLException;
   4:         ...
   5: 
   6:     public static void logAndClearWarnings(Connection con) throws SQLException
   7:     {
   8:         ...
   9:         {
  10:             for(SQLWarning w = con.getWarnings(); w != null; w = w.getNextWarning())
  11:                 logger.log(MLevel.INFO, w.getMessage(), w);

View Full Code Here
   1:             System.out.println("Obtention de la connexion");
   2:             Connection conn = DriverManager.getConnection(dbURL, 
   3: 
   4:         ...
   5: 
   6:             SQLWarning warn = conn.getWarnings();
   7:             while (warn != null) {
   8:                 System.out.println("SQLState :    " + warn.getSQLState());
   9:                 System.out.println("Message :     " + warn.getMessage());

View Full Code Here
   1: 
   2: import java.sql.Connection;
   3: import java.sql.SQLException;
   4:         ...
   5:     
   6:     public static void logAndClearWarnings(Connection connection) {
   7:         if ( log.isWarnEnabled() ) {
   8:         ...
   9:             try {
  10:                 logWarnings( connection.getWarnings() );
  11:                 connection.clearWarnings();

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: class C3P0Connection implements Connection
   7: {
   8:         ...
   9:     final Connection inner;
  10: 
  11:         ...
  12:     {
  13:         return inner.getWarnings();

View Full Code Here

isClosed

public boolean isClosed()
            throws SQLException
Retrieves whether this Connection object has been closed. A connection is closed if the method close has been called on it or if certain fatal errors have occurred. This method is guaranteed to return true only when it is called after the method Connection.close has been called.

This method generally cannot be called to determine whether a connection to a database is valid or invalid. A typical client can determine that a connection is invalid by catching any exceptions that might be thrown when an operation is attempted.

Returns:
true if this Connection object is closed; false if it is still open
Throws:
SQLException - if a database access error occurs
Usages and Demos :

View More Examples of isClosed()
   1:   private PostgisDSMetadata dbMetadata;
   2:   private Connection connection;
   3: 
   4:         ...
   5:   public PostgisDSConnection(Connection conn) {
   6:     connection = conn;
   7:         ...
   8:     try {
   9:         return connection.isClosed();
  10:     } catch (SQLException e) {

View Full Code Here
   1:         
   2:         Connection connection = ConnectionManager.getJNDIConnection(name);
   3:         ...
   4:         Assert.assertNotNull(connection);
   5:         
   6:         ...
   7:         ConnectionManager.closeConnection(connection);
   8:         Assert.assertTrue(connection.isClosed());
   9:     }
  10:         ...
  11:         ConnectionManager.closeConnection(connection);
  12:         Assert.assertTrue(connection.isClosed());

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: class C3P0Connection implements Connection
   7: {
   8:         ...
   9:     final Connection inner;
  10: 
  11:         ...
  12:     {
  13:         return inner.isClosed();

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: public abstract class FilterConnection implements Connection
   7: {
   8:         ...
   9:     protected Connection inner;
  10:     
  11:         ...
  12:     public boolean isClosed() throws SQLException
  13:     { return inner.isClosed(); }

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: public abstract class SynchronizedFilterConnection implements Connection
   7: {
   8:         ...
   9:     protected Connection inner;
  10:     
  11:         ...
  12:     public synchronized boolean isClosed() throws SQLException
  13:     { return inner.isClosed(); }

View Full Code Here

isReadOnly

public boolean isReadOnly()
            throws SQLException
Retrieves whether this Connection object is in read-only mode.
Returns:
true if this Connection object is read-only; false otherwise
Throws:
SQLException - if a database access error occurs
Usages and Demos :

View More Examples of isReadOnly()
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: class C3P0Connection implements Connection
   7: {
   8:         ...
   9:     final Connection inner;
  10: 
  11:         ...
  12:     {
  13:         return inner.isReadOnly();

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: public abstract class FilterConnection implements Connection
   7: {
   8:         ...
   9:     protected Connection inner;
  10:     
  11:         ...
  12:     public boolean isReadOnly() throws SQLException
  13:     { return inner.isReadOnly(); }

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: public abstract class SynchronizedFilterConnection implements Connection
   7: {
   8:         ...
   9:     protected Connection inner;
  10:     
  11:         ...
  12:     public synchronized boolean isReadOnly() throws SQLException
  13:     { return inner.isReadOnly(); }

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: class PooledConnection implements Connection {
   7:         ...
   8:     Connection con = null;
   9:     ConnectionPool pool = null;
  10:         ...
  11:     public boolean isReadOnly() throws SQLException {
  12:         return con.isReadOnly();

View Full Code Here
   1: 
   2: import java.sql.Connection;
   3: import java.sql.DriverManager;
   4:         ...
   5: 
   6:         Connection c1 = DriverManager.getConnection(url);
   7: 
   8:         ...
   9:         Connection c2 = DriverManager.getConnection(url);
  10: 
  11:         ...
  12: 
  13:         boolean originalReadOnly = c1.isReadOnly();

View Full Code Here

nativeSQL

public String nativeSQL(String sql)
            throws SQLException
Converts the given SQL statement into the system's native SQL grammar. A driver may convert the JDBC SQL grammar into its system's native SQL grammar prior to sending it. This method returns the native form of the statement that the driver would have sent.
Parameters:
sql - an SQL statement that may contain one or more '?' parameter placeholders
Returns:
the native form of this statement
Throws:
SQLException - if a database access error occurs
Usages and Demos :

View More Examples of nativeSQL(String sql)
   1:     };
   2:     Connection conn;
   3:         ...
   4:     void test(Connection conn) throws SQLException {
   5:         this.conn=conn;
   6:         ...
   7:         try {
   8:             String result=conn.nativeSQL(original);
   9:             trace("result: <"+result+">");

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: class C3P0Connection implements Connection
   7: {
   8:         ...
   9:     final Connection inner;
  10: 
  11:         ...
  12:     {
  13:         return inner.nativeSQL(a);

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: public abstract class FilterConnection implements Connection
   7: {
   8:         ...
   9:     protected Connection inner;
  10:     
  11:         ...
  12:     public String nativeSQL(String a) throws SQLException
  13:     { return inner.nativeSQL(a); }

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: public abstract class SynchronizedFilterConnection implements Connection
   7: {
   8:         ...
   9:     protected Connection inner;
  10:     
  11:         ...
  12:     public synchronized String nativeSQL(String a) throws SQLException
  13:     { return inner.nativeSQL(a); }

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: class PooledConnection implements Connection {
   7:         ...
   8:     Connection con = null;
   9:     ConnectionPool pool = null;
  10:         ...
  11:     public String nativeSQL(String sql) throws SQLException {
  12:         return con.nativeSQL(sql);

View Full Code Here

prepareCall

public CallableStatement prepareCall(String sql)
            throws SQLException
Creates a CallableStatement object for calling database stored procedures. The CallableStatement object provides methods for setting up its IN and OUT parameters, and methods for executing the call to a stored procedure.

Note: This method is optimized for handling stored procedure call statements. Some drivers may send the call statement to the database when the method prepareCall is done; others may wait until the CallableStatement object is executed. This has no direct effect on users; however, it does affect which method throws certain SQLExceptions.

Result sets created using the returned CallableStatement object will by default be type TYPE_FORWARD_ONLY and have a concurrency level of CONCUR_READ_ONLY.

Parameters:
sql - an SQL statement that may contain one or more '?' parameter placeholders. Typically this statement is a JDBC function call escape string.
Returns:
a new default CallableStatement object containing the pre-compiled SQL statement
Throws:
SQLException - if a database access error occurs
Usages and Demos :

View More Examples of prepareCall(String sql)
   1:      public
   2:      PreparedStatement buildStatement(Connection oConn,String sSQL)
   3:       throws SQLException{
   4:         ...
   5:         
   6:         return oConn.prepareCall(sSQL);
   7:      }
   8:         ...
   9:      public
  10:      PreparedStatement buildStatement(Connection oConn,String sSQL,int iResultsetType,int iResultsetConcurrency)
  11:       throws SQLException{

View Full Code Here
   1: import java.sql.PreparedStatement;
   2: import java.sql.Connection;
   3: import java.sql.SQLException;
   4:         ...
   5: 
   6:    protected PreparedStatement prepareStatement(Connection c, String sql, EntityEnterpriseContext ctx) throws SQLException
   7:    {
   8:         ...
   9:       return c.prepareCall(sql);
  10:    }

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: class PooledConnection implements Connection {
   7:         ...
   8:     Connection con = null;
   9:     ConnectionPool pool = null;
  10:         ...
  11:     public CallableStatement prepareCall(String sql) throws SQLException {
  12:         return con.prepareCall(sql);

View Full Code Here
   1: 
   2:     public  static  void    commit( Connection conn )
   3:         throws SQLException
   4:         ...
   5:     
   6:     public  static  void    executeDDL( Connection conn, String text )
   7:         throws SQLException
   8:         ...
   9:     
  10:     public  static  void    executeCall( Connection conn, String text )
  11:         throws SQLException
  12:         ...
  13: 
  14:         return conn.prepareCall( text );

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: public class PoolableConnection extends AbstractPoolableObject implements Connection {
   7:         ...
   8:     private Connection conn;
   9:     private ConnectionPool pool;
  10:         ...
  11:         checkClosed();
  12:         return conn.prepareCall(sql);

View Full Code Here

prepareCall

public CallableStatement prepareCall(String sql,
                                     int resultSetType,
                                     int resultSetConcurrency)
            throws SQLException
Creates a CallableStatement object that will generate ResultSet objects with the given type and concurrency. This method is the same as the prepareCall method above, but it allows the default result set type and concurrency to be overridden.
Parameters:
sql - a String object that is the SQL statement to be sent to the database; may contain on or more ? parameters
resultSetType - a result set type; one of ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE, or ResultSet.TYPE_SCROLL_SENSITIVE
resultSetConcurrency - a concurrency type; one of ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE
Returns:
a new CallableStatement object containing the pre-compiled SQL statement that will produce ResultSet objects with the given type and concurrency
Throws:
SQLException - if a database access error occurs or the given parameters are not ResultSet constants indicating type and concurrency
Since:
1.2
Usages and Demos :

View More Examples of prepareCall(String sql,int resultSetType,int resultSetConcurrency)
   1:      public
   2:      PreparedStatement buildStatement(Connection oConn,String sSQL)
   3:       throws SQLException{
   4:         ...
   5:      public
   6:      PreparedStatement buildStatement(Connection oConn,String sSQL,int iResultsetType,int iResultsetConcurrency)
   7:       throws SQLException{
   8:         ...
   9: 
  10:         return oConn.prepareCall(sSQL,iResultsetType,iResultsetConcurrency);
  11:      }

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: class C3P0Connection implements Connection
   7: {
   8:         ...
   9:     final Connection inner;
  10: 
  11:         ...
  12:     {
  13:         return inner.prepareCall(a, b, c);

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: public abstract class FilterConnection implements Connection
   7: {
   8:         ...
   9:     protected Connection inner;
  10:     
  11:         ...
  12:     public CallableStatement prepareCall(String a, int b, int c) throws SQLException
  13:     { return inner.prepareCall(a, b, c); }

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: public abstract class SynchronizedFilterConnection implements Connection
   7: {
   8:         ...
   9:     protected Connection inner;
  10:     
  11:         ...
  12:     public synchronized CallableStatement prepareCall(String a, int b, int c) throws SQLException
  13:     { return inner.prepareCall(a, b, c); }

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: class PooledConnection implements Connection {
   7:         ...
   8:     Connection con = null;
   9:     ConnectionPool pool = null;
  10:         ...
  11:                                          int resultSetConcurrency) throws SQLException {
  12:         return con.prepareCall(sql, resultSetType, resultSetConcurrency);

View Full Code Here

prepareCall

public CallableStatement prepareCall(String sql,
                                     int resultSetType,
                                     int resultSetConcurrency,
                                     int resultSetHoldability)
            throws SQLException
Creates a CallableStatement object that will generate ResultSet objects with the given type and concurrency. This method is the same as the prepareCall method above, but it allows the default result set type, result set concurrency type and holdability to be overridden.
Parameters:
sql - a String object that is the SQL statement to be sent to the database; may contain on or more ? parameters
resultSetType - one of the following ResultSet constants: ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE, or ResultSet.TYPE_SCROLL_SENSITIVE
resultSetConcurrency - one of the following ResultSet constants: ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE
resultSetHoldability - one of the following ResultSet constants: ResultSet.HOLD_CURSORS_OVER_COMMIT or ResultSet.CLOSE_CURSORS_AT_COMMIT
Returns:
a new CallableStatement object, containing the pre-compiled SQL statement, that will generate ResultSet objects with the given type, concurrency, and holdability
Throws:
SQLException - if a database access error occurs or the given parameters are not ResultSet constants indicating type, concurrency, and holdability
Since:
1.4
See Also:
ResultSet
Usages and Demos :

View More Examples of prepareCall(String sql,int resultSetType,int resultSetConcurrency,int resultSetHoldability)
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: public abstract class FilterConnection implements Connection
   7: {
   8:         ...
   9:     protected Connection inner;
  10:     
  11:         ...
  12:     public CallableStatement prepareCall(String a, int b, int c, int d) throws SQLException
  13:     { return inner.prepareCall(a, b, c, d); }

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: public abstract class SynchronizedFilterConnection implements Connection
   7: {
   8:         ...
   9:     protected Connection inner;
  10:     
  11:         ...
  12:     public synchronized CallableStatement prepareCall(String a, int b, int c, int d) throws SQLException
  13:     { return inner.prepareCall(a, b, c, d); }

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: class PooledConnection implements Connection {
   7:         ...
   8:     Connection con = null;
   9:     ConnectionPool pool = null;
  10:         ...
  11:                                          int resultSetHoldability) throws SQLException {
  12:         return con.prepareCall(sql, resultSetType, resultSetConcurrency, resultSetHoldability);

View Full Code Here
   1: public class TraceConnection
   2:         implements Connection
   3: {
   4:         ...
   5:     protected Connection conn;
   6:     
   7:         ...
   8:     public TraceConnection(Connection co) 
   9:     {
  10:         ...
  11:     {
  12:         CallableStatement stm = conn.prepareCall(sql,resultSetType,resultSetConcurrency,resultSetHoldability);

View Full Code Here
   1: 
   2: public class ConnectionAdapter implements Connection {
   3: 
   4:         ...
   5:     protected Connection connection;
   6: 
   7:         ...
   8:                               throws SQLException {
   9:                    return connection.prepareCall(sql,resultSetType,resultSetConcurrency,resultSetHoldability);
  10:                               }

View Full Code Here

prepareStatement

public PreparedStatement prepareStatement(String sql)
            throws SQLException
Creates a PreparedStatement object for sending parameterized SQL statements to the database.

A SQL statement with or without IN parameters can be pre-compiled and stored in a PreparedStatement object. This object can then be used to efficiently execute this statement multiple times.

Note: This method is optimized for handling parametric SQL statements that benefit from precompilation. If the driver supports precompilation, the method prepareStatement will send the statement to the database for precompilation. Some drivers may not support precompilation. In this case, the statement may not be sent to the database until the PreparedStatement object is executed. This has no direct effect on users; however, it does affect which methods throw certain SQLException objects.

Result sets created using the returned PreparedStatement object will by default be type TYPE_FORWARD_ONLY and have a concurrency level of CONCUR_READ_ONLY.

Parameters:
sql - an SQL statement that may contain one or more '?' IN parameter placeholders
Returns:
a new default PreparedStatement object containing the pre-compiled SQL statement
Throws:
SQLException - if a database access error occurs
Usages and Demos :

View More Examples of prepareStatement(String sql)
   1: 
   2: import java.sql.Connection;
   3: import java.sql.SQLException;
   4:         ...
   5:        int result = 0;
   6:        Connection connection = null;
   7:        PreparedStatement statement = null;
   8:         ...
   9:            statement =
  10:                 connection.prepareStatement(Commands.KEYS_NEXT);
  11:            statement.setString(1,keyName);
  12:         ...
  13:            statement =
  14:                 connection.prepareStatement(Commands.KEYS_NEXT);

View Full Code Here
   1:     {
   2:     Connection c = null;
   3:     PreparedStatement ps = null;
   4:         ...
   5:             PreparedStatement test = 
   6:                 c.prepareStatement( EMPTY_TABLE_CONDITIONAL_SELECT );
   7:             test.close();
   8:         ...
   9:     System.err.println("Creating test schema.");
  10:     Connection        con = null;
  11:     PreparedStatement ps1 = null;
  12:         ...
  13:         con = ds.getConnection();
  14:         ps1 = con.prepareStatement(EMPTY_TABLE_CREATE);

View Full Code Here
   1: 
   2: import java.sql.Connection;
   3: import java.sql.DriverManager;
   4:         ...
   5: 
   6:     protected Connection connection;
   7: 
   8:         ...
   9:         PreparedStatement ps = 
  10:             connection.prepareStatement(INSERT_INTO_TABLE_STATEMENT);
  11: 
  12:         ...
  13:         PreparedStatement ps = 
  14:             connection.prepareStatement(INSERT_INTO_TABLE_STATEMENT);

View Full Code Here
   1: 
   2: import java.sql.Connection;
   3: import java.sql.PreparedStatement;
   4:         ...
   5:         HsqldbTransaction hsqldbTransaction = (HsqldbTransaction) transaction;
   6:         Connection connection = hsqldbTransaction.getConnection();
   7:         PreparedStatement statement = null;
   8:         ...
   9:             statement = new DebugPreparedStatement(
  10:                     connection.prepareStatement(DELETE_SV_PROPERTY_STATEMENT),
  11:                     DELETE_SV_PROPERTY_STATEMENT);
  12:         ...
  13:             statement = new DebugPreparedStatement(
  14:                     connection.prepareStatement(DELETE_NODE_STATEMENT),

View Full Code Here

prepareStatement

public PreparedStatement prepareStatement(String sql,
                                          columnIndexes[] )
            throws SQLException
Creates a default PreparedStatement object capable of returning the auto-generated keys designated by the given array. This array contains the indexes of the columns in the target table that contain the auto-generated keys that should be made available. This array is ignored if the SQL statement is not an INSERT statement.

An SQL statement with or without IN parameters can be pre-compiled and stored in a PreparedStatement object. This object can then be used to efficiently execute this statement multiple times.

Note: This method is optimized for handling parametric SQL statements that benefit from precompilation. If the driver supports precompilation, the method prepareStatement will send the statement to the database for precompilation. Some drivers may not support precompilation. In this case, the statement may not be sent to the database until the PreparedStatement object is executed. This has no direct effect on users; however, it does affect which methods throw certain SQLExceptions.

Result sets created using the returned PreparedStatement object will by default be type TYPE_FORWARD_ONLY and have a concurrency level of CONCUR_READ_ONLY.

Parameters:
sql - an SQL statement that may contain one or more '?' IN parameter placeholders
Returns:
a new PreparedStatement object, containing the pre-compiled statement, that is capable of returning the auto-generated keys designated by the given array of column indexes
Throws:
SQLException - if a database access error occurs
Since:
1.4
Usages and Demos :

View More Examples of prepareStatement(String sql,columnIndexes[] )
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: public abstract class FilterConnection implements Connection
   7: {
   8:         ...
   9:     protected Connection inner;
  10:     
  11:         ...
  12:     public PreparedStatement prepareStatement(String a, String[] b) throws SQLException
  13:     { return inner.prepareStatement(a, b); }

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: public abstract class SynchronizedFilterConnection implements Connection
   7: {
   8:         ...
   9:     protected Connection inner;
  10:     
  11:         ...
  12:     public synchronized PreparedStatement prepareStatement(String a, String[] b) throws SQLException
  13:     { return inner.prepareStatement(a, b); }

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: class PooledConnection implements Connection {
   7:         ...
   8:     Connection con = null;
   9:     ConnectionPool pool = null;
  10:         ...
  11:             throws SQLException {
  12:         return con.prepareStatement(sql, autoGeneratedKeys);

View Full Code Here
   1: 
   2: public abstract class ConnectionWrapper implements Connection {
   3:         ...
   4:     protected Connection con;
   5: 
   6:         ...
   7:     public  ConnectionWrapper(Connection c) {
   8:         con = c;
   9:         ...
  10:         setLastSQL(sql);
  11:         return con.prepareStatement(sql, autoGeneratedKeys);

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: class ConnectionProxy implements Connection {
   7:     
   8:         ...
   9:     private Connection con;
  10: 
  11:         ...
  12:         throws SQLException {
  13:         return con.prepareStatement(sql, autoGeneratedKeys);

View Full Code Here

prepareStatement

public PreparedStatement prepareStatement(String sql,
                                          columnNames[] )
            throws SQLException
Creates a default PreparedStatement object capable of returning the auto-generated keys designated by the given array. This array contains the names of the columns in the target table that contain the auto-generated keys that should be returned. This array is ignored if the SQL statement is not an INSERT statement.

An SQL statement with or without IN parameters can be pre-compiled and stored in a PreparedStatement object. This object can then be used to efficiently execute this statement multiple times.

Note: This method is optimized for handling parametric SQL statements that benefit from precompilation. If the driver supports precompilation, the method prepareStatement will send the statement to the database for precompilation. Some drivers may not support precompilation. In this case, the statement may not be sent to the database until the PreparedStatement object is executed. This has no direct effect on users; however, it does affect which methods throw certain SQLExceptions.

Result sets created using the returned PreparedStatement object will by default be type TYPE_FORWARD_ONLY and have a concurrency level of CONCUR_READ_ONLY.

Parameters:
sql - an SQL statement that may contain one or more '?' IN parameter placeholders
Returns:
a new PreparedStatement object, containing the pre-compiled statement, that is capable of returning the auto-generated keys designated by the given array of column names
Throws:
SQLException - if a database access error occurs
Since:
1.4
Usages and Demos :

View More Examples of prepareStatement(String sql,columnNames[] )
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: public abstract class FilterConnection implements Connection
   7: {
   8:         ...
   9:     protected Connection inner;
  10:     
  11:         ...
  12:     public PreparedStatement prepareStatement(String a, String[] b) throws SQLException
  13:     { return inner.prepareStatement(a, b); }

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: public abstract class SynchronizedFilterConnection implements Connection
   7: {
   8:         ...
   9:     protected Connection inner;
  10:     
  11:         ...
  12:     public synchronized PreparedStatement prepareStatement(String a, String[] b) throws SQLException
  13:     { return inner.prepareStatement(a, b); }

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: class PooledConnection implements Connection {
   7:         ...
   8:     Connection con = null;
   9:     ConnectionPool pool = null;
  10:         ...
  11:             throws SQLException {
  12:         return con.prepareStatement(sql, autoGeneratedKeys);

View Full Code Here
   1: 
   2: public abstract class ConnectionWrapper implements Connection {
   3:         ...
   4:     protected Connection con;
   5: 
   6:         ...
   7:     public  ConnectionWrapper(Connection c) {
   8:         con = c;
   9:         ...
  10:         setLastSQL(sql);
  11:         return con.prepareStatement(sql, autoGeneratedKeys);

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: class ConnectionProxy implements Connection {
   7:     
   8:         ...
   9:     private Connection con;
  10: 
  11:         ...
  12:         throws SQLException {
  13:         return con.prepareStatement(sql, autoGeneratedKeys);

View Full Code Here

prepareStatement

public PreparedStatement prepareStatement(String sql,
                                          int autoGeneratedKeys)
            throws SQLException
Creates a default PreparedStatement object that has the capability to retrieve auto-generated keys. The given constant tells the driver whether it should make auto-generated keys available for retrieval. This parameter is ignored if the SQL statement is not an INSERT statement.

Note: This method is optimized for handling parametric SQL statements that benefit from precompilation. If the driver supports precompilation, the method prepareStatement will send the statement to the database for precompilation. Some drivers may not support precompilation. In this case, the statement may not be sent to the database until the PreparedStatement object is executed. This has no direct effect on users; however, it does affect which methods throw certain SQLExceptions.

Result sets created using the returned PreparedStatement object will by default be type TYPE_FORWARD_ONLY and have a concurrency level of CONCUR_READ_ONLY.

Parameters:
sql - an SQL statement that may contain one or more '?' IN parameter placeholders
autoGeneratedKeys - a flag indicating whether auto-generated keys should be returned; one of Statement.RETURN_GENERATED_KEYS or Statement.NO_GENERATED_KEYS
Returns:
a new PreparedStatement object, containing the pre-compiled SQL statement, that will have the capability of returning auto-generated keys
Throws:
SQLException - if a database access error occurs or the given parameter is not a Statement constant indicating whether auto-generated keys should be returned
Since:
1.4
Usages and Demos :

View More Examples of prepareStatement(String sql,int autoGeneratedKeys)
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: public abstract class FilterConnection implements Connection
   7: {
   8:         ...
   9:     protected Connection inner;
  10:     
  11:         ...
  12:     public PreparedStatement prepareStatement(String a, String[] b) throws SQLException
  13:     { return inner.prepareStatement(a, b); }

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: public abstract class SynchronizedFilterConnection implements Connection
   7: {
   8:         ...
   9:     protected Connection inner;
  10:     
  11:         ...
  12:     public synchronized PreparedStatement prepareStatement(String a, String[] b) throws SQLException
  13:     { return inner.prepareStatement(a, b); }

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: class PooledConnection implements Connection {
   7:         ...
   8:     Connection con = null;
   9:     ConnectionPool pool = null;
  10:         ...
  11:             throws SQLException {
  12:         return con.prepareStatement(sql, autoGeneratedKeys);

View Full Code Here
   1: 
   2: public abstract class ConnectionWrapper implements Connection {
   3:         ...
   4:     protected Connection con;
   5: 
   6:         ...
   7:     public  ConnectionWrapper(Connection c) {
   8:         con = c;
   9:         ...
  10:         setLastSQL(sql);
  11:         return con.prepareStatement(sql, autoGeneratedKeys);

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: class ConnectionProxy implements Connection {
   7:     
   8:         ...
   9:     private Connection con;
  10: 
  11:         ...
  12:         throws SQLException {
  13:         return con.prepareStatement(sql, autoGeneratedKeys);

View Full Code Here

prepareStatement

public PreparedStatement prepareStatement(String sql,
                                          int resultSetType,
                                          int resultSetConcurrency)
            throws SQLException
Creates a PreparedStatement object that will generate ResultSet objects with the given type and concurrency. This method is the same as the prepareStatement method above, but it allows the default result set type and concurrency to be overridden.
Parameters:
sql - a String object that is the SQL statement to be sent to the database; may contain one or more ? IN parameters
resultSetType - a result set type; one of ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE, or ResultSet.TYPE_SCROLL_SENSITIVE
resultSetConcurrency - a concurrency type; one of ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE
Returns:
a new PreparedStatement object containing the pre-compiled SQL statement that will produce ResultSet objects with the given type and concurrency
Throws:
SQLException - if a database access error occurs or the given parameters are not ResultSet constants indicating type and concurrency
Since:
1.2
Usages and Demos :

View More Examples of prepareStatement(String sql,int resultSetType,int resultSetConcurrency)
   1:      public
   2:      PreparedStatement buildStatement(Connection oConn,String sSQL)
   3:       throws SQLException{
   4:         ...
   5:      public
   6:      PreparedStatement buildStatement(Connection oConn,String sSQL,int iResultsetType,int iResultsetConcurrency)
   7:       throws SQLException{
   8:         ...
   9: 
  10:         return oConn.prepareStatement(sSQL,iResultsetType,iResultsetConcurrency);
  11:      }

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: class C3P0Connection implements Connection
   7: {
   8:         ...
   9:     final Connection inner;
  10: 
  11:         ...
  12:     {
  13:         return inner.prepareStatement(a, b, c);

View Full Code Here
   1: 
   2: import java.sql.Connection;
   3: import java.sql.PreparedStatement;
   4:         ...
   5:         String sql;
   6:         Connection connection;
   7:         boolean scrollable;
   8:         ...
   9:                 ps = scrollable ?
  10:                     connection.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY) :
  11:                     connection.prepareStatement(sql);

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: public abstract class FilterConnection implements Connection
   7: {
   8:         ...
   9:     protected Connection inner;
  10:     
  11:         ...
  12:     public PreparedStatement prepareStatement(String a, int b, int c) throws SQLException
  13:     { return inner.prepareStatement(a, b, c); }

View Full Code Here
   1: 
   2: import java.sql.Connection;
   3: import java.sql.PreparedStatement;
   4:         ...
   5:         String sql;
   6:         Connection connection;
   7:         boolean scrollable;
   8:         ...
   9:                 ps = scrollable ?
  10:                     connection.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY) :
  11:                     connection.prepareStatement(sql);

View Full Code Here

prepareStatement

public PreparedStatement prepareStatement(String sql,
                                          int resultSetType,
                                          int resultSetConcurrency,
                                          int resultSetHoldability)
            throws SQLException
Creates a PreparedStatement object that will generate ResultSet objects with the given type, concurrency, and holdability.

This method is the same as the prepareStatement method above, but it allows the default result set type, concurrency, and holdability to be overridden.

Parameters:
sql - a String object that is the SQL statement to be sent to the database; may contain one or more ? IN parameters
resultSetType - one of the following ResultSet constants: ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE, or ResultSet.TYPE_SCROLL_SENSITIVE
resultSetConcurrency - one of the following ResultSet constants: ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE
resultSetHoldability - one of the following ResultSet constants: ResultSet.HOLD_CURSORS_OVER_COMMIT or ResultSet.CLOSE_CURSORS_AT_COMMIT
Returns:
a new PreparedStatement object, containing the pre-compiled SQL statement, that will generate ResultSet objects with the given type, concurrency, and holdability
Throws:
SQLException - if a database access error occurs or the given parameters are not ResultSet constants indicating type, concurrency, and holdability
Since:
1.4
See Also:
ResultSet
Usages and Demos :

View More Examples of prepareStatement(String sql,int resultSetType,int resultSetConcurrency,int resultSetHoldability)
   1:     }
   2:     public PreparedStatement createDuplicateStatement(Connection conn, PreparedStatement oldStatement) throws SQLException {
   3: 
   4:         ...
   5:         if (generatedKeys == null)
   6:             newStatement = conn.prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability);
   7:         else {
   8:             if (generatedKeys instanceof Integer)
   9:                 newStatement = conn.prepareStatement(sql, ((Integer) generatedKeys).intValue());

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: public abstract class FilterConnection implements Connection
   7: {
   8:         ...
   9:     protected Connection inner;
  10:     
  11:         ...
  12:     public PreparedStatement prepareStatement(String a, int b, int c, int d) throws SQLException
  13:     { return inner.prepareStatement(a, b, c, d); }

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: public abstract class SynchronizedFilterConnection implements Connection
   7: {
   8:         ...
   9:     protected Connection inner;
  10:     
  11:         ...
  12:     public synchronized PreparedStatement prepareStatement(String a, int b, int c, int d) throws SQLException
  13:     { return inner.prepareStatement(a, b, c, d); }

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: class PooledConnection implements Connection {
   7:         ...
   8:     Connection con = null;
   9:     ConnectionPool pool = null;
  10:         ...
  11:             throws SQLException {
  12:         return con.prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability);

View Full Code Here
   1: public class TraceConnection
   2:         implements Connection
   3: {
   4:         ...
   5:     protected Connection conn;
   6:     
   7:         ...
   8:     public TraceConnection(Connection co) 
   9:     {
  10:         ...
  11:     {
  12:         PreparedStatement stm = conn.prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability);

View Full Code Here

releaseSavepoint

public void releaseSavepoint(Savepoint savepoint)
            throws SQLException
Removes the given Savepoint object from the current transaction. Any reference to the savepoint after it have been removed will cause an SQLException to be thrown.
Parameters:
savepoint - the Savepoint object to be removed
Throws:
SQLException - if a database access error occurs or the given Savepoint object is not a valid savepoint in the current transaction
Since:
1.4
Usages and Demos :

View More Examples of releaseSavepoint(Savepoint savepoint)
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: public abstract class FilterConnection implements Connection
   7: {
   8:         ...
   9:     protected Connection inner;
  10:     
  11:         ...
  12:     public void releaseSavepoint(Savepoint a) throws SQLException
  13:     { inner.releaseSavepoint(a); }

View Full Code Here
   1: 
   2: import java.sql.Connection;
   3: import java.sql.DriverManager;
   4:         ...
   5:     static private boolean classLoaded = false;
   6:     public Connection conn = null;
   7:     public boolean isReadOnly = true;
   8:         ...
   9:     }
  10:     public LSDDbSession(Connection connext, boolean isReadOnly) {
  11:         if (connext == null)
  12:         ...
  13:         try {
  14:             conn.releaseSavepoint(savepoint);

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: public abstract class SynchronizedFilterConnection implements Connection
   7: {
   8:         ...
   9:     protected Connection inner;
  10:     
  11:         ...
  12:     public synchronized void releaseSavepoint(Savepoint a) throws SQLException
  13:     { inner.releaseSavepoint(a); }

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: class PooledConnection implements Connection {
   7:         ...
   8:     Connection con = null;
   9:     ConnectionPool pool = null;
  10:         ...
  11:     public void releaseSavepoint(Savepoint savepoint) throws SQLException {
  12:         con.releaseSavepoint(savepoint);

View Full Code Here
   1: public class TraceConnection
   2:         implements Connection
   3: {
   4:         ...
   5:     protected Connection conn;
   6:     
   7:         ...
   8:     public TraceConnection(Connection co) 
   9:     {
  10:         ...
  11:     public void rollback(Savepoint savepoint) throws SQLException { conn.rollback(savepoint); }
  12:     public void releaseSavepoint(Savepoint savepoint) throws SQLException { conn.releaseSavepoint(savepoint); }

View Full Code Here

rollback

public void rollback()
            throws SQLException
Undoes all changes made in the current transaction and releases any database locks currently held by this Connection object. This method should be used only when auto-commit mode has been disabled.
Throws:
SQLException - if a database access error occurs or this Connection object is in auto-commit mode
Usages and Demos :

View More Examples of rollback()
   1:   public static void main(String args[])throws Exception{
   2:     Connection con=new ConnectionProvider().getConnection();
   3:     try{
   4:       con.setAutoCommit(false);
   5:       Statement stmt=con.createStatement();

View Full Code Here
   1:     Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); 
   2:     Connection c = DriverManager.getConnection("jdbc:odbc:Kurse");
   3:     DatabaseMetaData dbmd = c.getMetaData();
   4:         ...
   5:     s.execute("INSERT INTO Teilnehmer(pcode,kcode) VALUES (555,555)");
   6:     c.rollback();    s.execute("INSERT INTO Teilnehmer(pcode,kcode) VALUES (666,666)");
   7:     s.execute("INSERT INTO Teilnehmer(pcode,kcode) VALUES (777,777)");
   8:         ...
   9:     c.rollback();
  10:     c.setAutoCommit(true);
  11:         ...
  12:     s.execute("INSERT INTO Teilnehmer(pcode,kcode) VALUES (999,999)");
  13:     c.rollback();

View Full Code Here
   1:     catch (SQLException e) {
   2:       try { con.rollback(); } catch (SQLException ignored) { }
   3:     }
   4:         ...
   5: 
   6:   private Connection establishConnection() throws SQLException {
   7:   }
   8: }

View Full Code Here
   1: 
   2:     Connection con = null;
   3:     try {
   4:         ...
   5:       try { 
   6:         con.rollback();
   7:       }
   8:       catch (Exception ignored) { } 
   9:       out.println("Order failed.  Please contact technical support.");

View Full Code Here
   1:   public static void main(String args[]) {
   2:     Connection con = null;
   3: 
   4:     if( args.length != 2 ) {
   5:       System.out.println("Syntax: <java UpdateLogic [number] [string]>");

View Full Code Here

rollback

public void rollback(Savepoint savepoint)
            throws SQLException
Undoes all changes made after the given Savepoint object was set.

This method should be used only when auto-commit has been disabled.

Parameters:
savepoint - the Savepoint object to roll back to
Throws:
SQLException - if a database access error occurs, the Savepoint object is no longer valid, or this Connection object is currently in auto-commit mode
Since:
1.4
See Also:
Savepoint, rollback
Usages and Demos :

View More Examples of rollback(Savepoint savepoint)
   1:   public static void main(String args[])throws Exception{
   2:     Connection con=new ConnectionProvider().getConnection();
   3:     try{
   4:         ...
   5:       stmt.executeUpdate("update ACCOUNTS set BALANCE=900 where ID=1");
   6:       con.rollback(sp);
   7:       stmt.executeUpdate("insert into ACCOUNTS(ID,NAME,BALANCE)"
   8:         +"values(2,'Jack',1000)");
   9:       con.commit();

View Full Code Here
   1: 
   2:     public pointcut connectionActivities(Connection conn)
   3:         ...
   4:     : (call(* Connection.commit(..))
   5:         ...
   6:        || call(* Connection.rollback(..)))
   7:     && target(conn);
   8:         ...
   9:     : accountActivities()
  10:     || connectionActivities(Connection)

View Full Code Here
   1: import java.sql.PreparedStatement;
   2: import java.sql.Connection;
   3: import book.util.JDBCUtil;
   4:         ...
   5:   {
   6:     Connection conn = null;
   7:     PreparedStatement pstmtLog = null;
   8:         ...
   9:       {
  10:         conn.rollback( savepoint );
  11:         _log( pstmtLog, "demo_savepoint", "Failed with error: " + e.getMessage());

View Full Code Here
   1:     public void execute() {
   2:         Connection connection = null;
   3:         Statement statement = null;
   4:         ...
   5:             String url = "jdbc:hsqldb:hsqldb\\chapter04";
   6:             connection = DriverManager.getConnection( url, username, password );
   7:             connection.setAutoCommit(false);
   8:         ...
   9: 
  10:             connection.rollback(savepoint3);
  11:             connection.commit();

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: public abstract class FilterConnection implements Connection
   7: {
   8:         ...
   9:     protected Connection inner;
  10:     
  11:         ...
  12:     public void rollback(Savepoint a) throws SQLException
  13:     { inner.rollback(a); }

View Full Code Here

setAutoCommit

public void setAutoCommit(boolean autoCommit)
            throws SQLException
Sets this connection's auto-commit mode to the given state. If a connection is in auto-commit mode, then all its SQL statements will be executed and committed as individual transactions. Otherwise, its SQL statements are grouped into transactions that are terminated by a call to either the method commit or the method rollback. By default, new connections are in auto-commit mode.

The commit occurs when the statement completes or the next execute occurs, whichever comes first. In the case of statements returning a ResultSet object, the statement completes when the last row of the ResultSet object has been retrieved or the ResultSet object has been closed. In advanced cases, a single statement may return multiple results as well as output parameter values. In these cases, the commit occurs when all results and output parameter values have been retrieved.

NOTE: If this method is called during a transaction, the transaction is committed.

Parameters:
autoCommit - true to enable auto-commit mode; false to disable it
Throws:
SQLException - if a database access error occurs
Usages and Demos :

View More Examples of setAutoCommit(boolean autoCommit)
   1: 
   2: import java.sql.Connection;
   3: import java.sql.SQLException;
   4:         ...
   5: import net.sf.hibernate.HibernateException;
   6: import net.sf.hibernate.connection.ConnectionProvider;
   7: 
   8:         ...
   9: 
  10:   public Connection getConnection() throws SQLException {
  11:     PortalContainer container = PortalContainer.getInstance();
  12:         ...
  13:     Connection conn = ds.getConnection() ;
  14:     conn.setAutoCommit(autocommit_) ;

View Full Code Here
   1: import net.sf.hibernate.HibernateException;
   2: import net.sf.hibernate.connection.ConnectionProvider;
   3: 
   4:         ...
   5: import org.exoplatform.services.database.DatabaseService;
   6: import java.sql.Connection;
   7: import java.sql.SQLException;
   8:         ...
   9: 
  10:   public Connection getConnection() throws SQLException {
  11:     PortalContainer container = PortalContainer.getInstance();
  12:         ...
  13:     Connection conn = ds.getConnection() ;
  14:     conn.setAutoCommit(autocommit_) ;

View Full Code Here
   1: public class ConnectionBean implements HttpSessionBindingListener {
   2:   private Connection connection;
   3:   private Statement statement;
   4:         ...
   5:       Class.forName(driver);
   6:       connection=DriverManager.getConnection(dbURL,login,password);
   7:       statement=connection.createStatement();
   8:         ...
   9:     throws SQLException {
  10:     connection.setAutoCommit(autoCommit );
  11:   }

View Full Code Here
   1: 
   2: import java.sql.Connection;
   3: import java.sql.DriverManager;
   4:         ...
   5: 
   6:     public void closeConnection(Connection connection) {
   7: 
   8:         ...
   9:                 if (!connection.getAutoCommit()) {
  10:                     connection.setAutoCommit(true);
  11:                 }
  12:         ...
  13:                 this.username, this.password);
  14:         connection.setAutoCommit(autoCommit);

View Full Code Here
   1: 
   2:   Connection connection;
   3: 
   4:         ...
   5:       insertTracks(data);
   6:       connection.commit();
   7:       System.out.println("All data has been entered and committed");
   8:         ...
   9:     connection = ConnectionFactory.getConnection();
  10:     connection.setAutoCommit(autocommit);
  11:   } 

View Full Code Here

setCatalog

public void setCatalog(String catalog)
            throws SQLException
Sets the given catalog name in order to select a subspace of this Connection object's database in which to work.

If the driver does not support catalogs, it will silently ignore this request.

Parameters:
catalog - the name of a catalog (subspace in this Connection object's database) in which to work
Throws:
SQLException - if a database access error occurs
See Also:
getCatalog()
Usages and Demos :

View More Examples of setCatalog(String catalog)
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: class C3P0Connection implements Connection
   7: {
   8:         ...
   9:     final Connection inner;
  10: 
  11:         ...
  12:     {
  13:         inner.setCatalog(a);

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: class PooledConnection implements Connection {
   7:         ...
   8:     Connection con = null;
   9:     ConnectionPool pool = null;
  10:         ...
  11:     public void setCatalog(String catalog) throws SQLException {
  12:         con.setCatalog(catalog);

View Full Code Here
   1: 
   2: import java.sql.Connection;
   3: import java.sql.PreparedStatement;
   4:         ...
   5:     public void testPreparedStatementPooling() throws Exception {
   6:         Connection conn = getConnection();
   7:         assertNotNull(conn);
   8:         ...
   9:     public void testPStmtCatalog() throws Exception {
  10:         Connection conn = getConnection();
  11:         ...
  12:         conn.setCatalog("catalog1");

View Full Code Here
   1: 
   2: public class ConnectionAdapter implements Connection {
   3: 
   4:         ...
   5:     protected Connection connection;
   6: 
   7:         ...
   8:     public void setCatalog(String catalog) throws SQLException {
   9:         connection.setCatalog(catalog);
  10:     }

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: public class PoolableConnection extends AbstractPoolableObject implements Connection {
   7:         ...
   8:     private Connection conn;
   9:     private ConnectionPool pool;
  10:         ...
  11:         checkClosed();
  12:         conn.setCatalog(catalog);

View Full Code Here

setHoldability

public void setHoldability(int holdability)
            throws SQLException
Changes the holdability of ResultSet objects created using this Connection object to the given holdability.
Parameters:
holdability - a ResultSet holdability constant; one of ResultSet.HOLD_CURSORS_OVER_COMMIT or ResultSet.CLOSE_CURSORS_AT_COMMIT
Throws:
SQLException - if a database access occurs, the given parameter is not a ResultSet constant indicating holdability, or the given holdability is not supported
Since:
1.4
Usages and Demos :

View More Examples of setHoldability(int holdability)
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: public abstract class FilterConnection implements Connection
   7: {
   8:         ...
   9:     protected Connection inner;
  10:     
  11:         ...
  12:     public void setHoldability(int a) throws SQLException
  13:     { inner.setHoldability(a); }

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: public abstract class SynchronizedFilterConnection implements Connection
   7: {
   8:         ...
   9:     protected Connection inner;
  10:     
  11:         ...
  12:     public synchronized void setHoldability(int a) throws SQLException
  13:     { inner.setHoldability(a); }

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: class PooledConnection implements Connection {
   7:         ...
   8:     Connection con = null;
   9:     ConnectionPool pool = null;
  10:         ...
  11:     public void setHoldability(int holdability) throws SQLException {
  12:         con.setHoldability(holdability);

View Full Code Here
   1: public class TraceConnection
   2:         implements Connection
   3: {
   4:         ...
   5:     protected Connection conn;
   6:     
   7:         ...
   8:     public TraceConnection(Connection co) 
   9:     {
  10:         ...
  11: 
  12:     public void setHoldability(int holdability) throws SQLException { conn.setHoldability(holdability);   }

View Full Code Here
   1: 
   2: public class ConnectionAdapter implements Connection {
   3: 
   4:         ...
   5:     protected Connection connection;
   6: 
   7:         ...
   8:     public void setHoldability(int holdability) throws SQLException {
   9:         connection.setHoldability(holdability);
  10:     }

View Full Code Here

setReadOnly

public void setReadOnly(boolean readOnly)
            throws SQLException
Puts this connection in read-only mode as a hint to the driver to enable database optimizations.

Note: This method cannot be called during a transaction.

Parameters:
readOnly - true enables read-only mode; false disables it
Throws:
SQLException - if a database access error occurs or this method is called during a transaction
Usages and Demos :

View More Examples of setReadOnly(boolean readOnly)
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: class C3P0Connection implements Connection
   7: {
   8:         ...
   9:     final Connection inner;
  10: 
  11:         ...
  12:     {
  13:         inner.setReadOnly(a);

View Full Code Here
   1: 
   2: import java.sql.Connection;
   3: import java.sql.DriverManager;
   4:         ...
   5:     static private boolean classLoaded = false;
   6:     public Connection conn = null;
   7:     public boolean isReadOnly = true;
   8:         ...
   9:     }
  10:     public LSDDbSession(Connection connext, boolean isReadOnly) {
  11:         if (connext == null)
  12:         ...
  13:             this.isReadOnly = isReadOnly;
  14:             conn.setReadOnly(this.isReadOnly);

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: class PooledConnection implements Connection {
   7:         ...
   8:     Connection con = null;
   9:     ConnectionPool pool = null;
  10:         ...
  11:     public void setReadOnly(boolean readOnly) throws SQLException {
  12:         con.setReadOnly(readOnly);

View Full Code Here
   1: 
   2: import java.sql.Connection;
   3: import java.sql.SQLException;
   4:         ...
   5:     protected String getFinalizeWarning() {
   6:         return "A Transaction was not closed. Temporary connection pool leak now closed.";
   7:     }
   8:         ...
   9:     protected void setConnectionProperties() throws SQLException {
  10:         Connection con = getActiveConnection();
  11:         if (con.isReadOnly()) {
  12:         ...
  13:             con.setReadOnly(false);

View Full Code Here
   1: 
   2:         log.info( "Attempting connection to database with url=" + databaseURL + " and username=" + username );
   3: 
   4:         ...
   5:         connection = DriverManager.getConnection( databaseURL, username, password );
   6:         ...
   7:         log.debug( "Connection " + connection );
   8:         stmt = connection.createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE,
   9:         ...
  10:         try {
  11:             connection.setReadOnly(readOnly);

View Full Code Here

setSavepoint

public Savepoint setSavepoint()
            throws SQLException
Creates an unnamed savepoint in the current transaction and returns the new Savepoint object that represents it.
Returns:
the new Savepoint object
Throws:
SQLException - if a database access error occurs or this Connection object is currently in auto-commit mode
Since:
1.4
See Also:
Savepoint
Usages and Demos :

View More Examples of setSavepoint()
   1:   public static void main(String args[])throws Exception{
   2:     Connection con=new ConnectionProvider().getConnection();
   3:     try{
   4:         ...
   5:         +"values(1,'Tom',1000)");
   6:       Savepoint sp=con.setSavepoint();
   7:       stmt.executeUpdate("update ACCOUNTS set BALANCE=900 where ID=1");
   8:       con.rollback(sp);
   9:       stmt.executeUpdate("insert into ACCOUNTS(ID,NAME,BALANCE)"

View Full Code Here
   1: import java.sql.PreparedStatement;
   2: import java.sql.Connection;
   3: import book.util.JDBCUtil;
   4:         ...
   5:   {
   6:     Connection conn = null;
   7:     PreparedStatement pstmtLog = null;
   8:         ...
   9:         _log( pstmtLog, "demo_savepoint", "starting the txn to demo savepoints at: " + new Date() );
  10:         savepoint = conn.setSavepoint();
  11:         pstmt = conn.prepareStatement( insertStmt ) ;

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: public abstract class FilterConnection implements Connection
   7: {
   8:         ...
   9:     protected Connection inner;
  10:     
  11:         ...
  12:     public Savepoint setSavepoint() throws SQLException
  13:     { return inner.setSavepoint(); }

View Full Code Here
   1: 
   2: import java.sql.Connection;
   3: import java.sql.DriverManager;
   4:         ...
   5:     static private boolean classLoaded = false;
   6:     public Connection conn = null;
   7:     public boolean isReadOnly = true;
   8:         ...
   9:     }
  10:     public LSDDbSession(Connection connext, boolean isReadOnly) {
  11:         if (connext == null)
  12:         ...
  13:         try {
  14:             return conn.setSavepoint();

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: public abstract class SynchronizedFilterConnection implements Connection
   7: {
   8:         ...
   9:     protected Connection inner;
  10:     
  11:         ...
  12:     public synchronized Savepoint setSavepoint() throws SQLException
  13:     { return inner.setSavepoint(); }

View Full Code Here

setSavepoint

public Savepoint setSavepoint(String name)
            throws SQLException
Creates a savepoint with the given name in the current transaction and returns the new Savepoint object that represents it.
Parameters:
name - a String containing the name of the savepoint
Returns:
the new Savepoint object
Throws:
SQLException - if a database access error occurs or this Connection object is currently in auto-commit mode
Since:
1.4
See Also:
Savepoint
Usages and Demos :

View More Examples of setSavepoint(String name)
   1:     public void execute() {
   2:         Connection connection = null;
   3:         Statement statement = null;
   4:         ...
   5:             String url = "jdbc:hsqldb:hsqldb\\chapter04";
   6:             connection = DriverManager.getConnection( url, username, password );
   7:             connection.setAutoCommit(false);
   8:         ...
   9:             statement.executeUpdate( update1 );
  10:             Savepoint savepoint1 = connection.setSavepoint("savepoint1");
  11: 
  12:         ...
  13:             statement.executeUpdate( update2 );
  14:             Savepoint savepoint2 = connection.setSavepoint("savepoint2");

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: public abstract class FilterConnection implements Connection
   7: {
   8:         ...
   9:     protected Connection inner;
  10:     
  11:         ...
  12:     public Savepoint setSavepoint(String a) throws SQLException
  13:     { return inner.setSavepoint(a); }

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: public abstract class SynchronizedFilterConnection implements Connection
   7: {
   8:         ...
   9:     protected Connection inner;
  10:     
  11:         ...
  12:     public synchronized Savepoint setSavepoint(String a) throws SQLException
  13:     { return inner.setSavepoint(a); }

View Full Code Here
   1: import java.sql.CallableStatement;
   2: import java.sql.Connection;
   3: import java.sql.DatabaseMetaData;
   4:         ...
   5: 
   6: class PooledConnection implements Connection {
   7:         ...
   8:     Connection con = null;
   9:     ConnectionPool pool = null;
  10:         ...
  11:     public Savepoint setSavepoint(String name) throws SQLException {
  12:         return con.setSavepoint(name);

View Full Code Here
   1: public class TraceConnection
   2:         implements Connection
   3: {
   4:         ...
   5:     protected Connection conn;
   6:     
   7:         ...
   8:     public TraceConnection(Connection co) 
   9:     {
  10:         ...
  11:     public Savepoint setSavepoint() throws SQLException { return conn.setSavepoint(); }
  12:     public Savepoint setSavepoint(String name) throws SQLException { return conn.setSavepoint(name); }

View Full Code Here

setTransactionIsolation

public void setTransactionIsolation(int level)
            throws SQLException
Attempts to change the transaction isolation level for this Connection object to the one given. The constants defined in the interface Connection are the possible transaction isolation levels.

Note: If this method is called during a transaction, the result is implementation-defined.

Parameters:
level - one of the following Connection constants: Connection.TRANSACTION_READ_UNCOMMITTED, Connection.TRANSACTION_READ_COMMITTED, Connection.TRANSACTION_REPEATABLE_READ, or Connection.TRANSACTION_SERIALIZABLE. (Note that Connection.TRANSACTION_NONE cannot be used because it specifies that transactions are not supported.)
Throws:
SQLException - if a database access error occurs or the given parameter is not one of the Connection constants
Usages and Demos :

View More Examples of setTransactionIsolation(int level)
   1: 
   2: import java.sql.Connection;
   3: import java.sql.SQLException;
   4:         ...
   5:     
   6:     private Connection connection;
   7: 
   8:         ...
   9:         try {
  10:             connection.setTransactionIsolation(isolationLevel);
  11:             return Boolean.TRUE;

View Full Code Here
   1:     Statement stat;
   2:     void test(Connection conn) throws SQLException {
   3:         trace("default TransactionIsolation="+conn.getTransactionIsolation());
   4:         ...
   5:         conn.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
   6:         ...
   7:         check(conn.getTransactionIsolation()==Connection.TRANSACTION_READ_COMMITTED);
   8:         ...
   9:         conn.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);

View Full Code Here
   1: import javax.sql.DataSource;
   2: import java.sql.Connection;
   3: import java.sql.SQLException;
   4:         ...
   5: 
   6:   private Connection _conn;
   7:   private int _oldIsolation;
   8:         ...
   9:         if (isolation.equals("read_committed"))
  10:           isolationCode = Connection.TRANSACTION_READ_COMMITTED;
  11:         else if (isolation.equals("read_uncommitted"))
  12:         ...
  13:       if (_isolation != null && isolationCode != _oldIsolation)
  14:         _conn.setTransactionIsolation(isolationCode);

View Full Code Here
   1: import javax.sql.DataSource;
   2: import java.sql.Connection;
   3: import java.sql.SQLException;
   4:         ...
   5: 
   6:   private Connection _conn;
   7:   private int _oldIsolation;
   8:         ...
   9:       else if (_isolation.equals("read_committed"))
  10:         isolationCode = Connection.TRANSACTION_READ_COMMITTED;
  11:       else if (_isolation.equals("read_uncommitted"))
  12:         ...
  13:       else {
  14:         _conn.setTransactionIsolation(isolationCode);

View Full Code Here
   1: import java.io.IOException;
   2: import java.sql.Connection;
   3: import java.sql.SQLException;
   4:         ...
   5: 
   6:     protected Connection getConnection(Transaction transaction) throws IOException {
   7:         if (transaction != Transaction.AUTO_COMMIT) {
   8:         ...
   9:         } catch (SQLException sqle) {
  10:             throw new DataSourceException("Connection failed:" + sqle, sqle);
  11:         }
  12:         ...
  13:                     if (getTransactionIsolation() != Connection.TRANSACTION_NONE) {
  14:                         conn.setTransactionIsolation(getTransactionIsolation());

View Full Code Here

setTypeMap

public void setTypeMap(java.util.Map> map)
            throws SQLException
Installs the given TypeMap object as the type map for this Connection object. The type map will be used for the custom mapping of SQL structured types and distinct types.
Parameters:
map - the java.util.Map object to install as the replacement for this Connection object's default type map
Throws:
SQLException - if a database access error occurs or the given parameter is not a java.util.Map object
Since:
1.2
See Also:
getTypeMap()