Connection Class

Used to connect to a database via JDBC

Constructors

public Connection( )
public Connection( java.sql.Connection conn )

Methods

close( ) returns void
Used to close a connection to the database, freeing up connections
commit( ) returns void
Used to explicitely commit changes made to the database.
execute( String sql ) returns void
Used to execute a prepared sql statement (e.g. "delete from my_table").
getConnection( ) returns java.sql.Connection
Used to retrieve the java.sql.Connection for this Connection
getConnectionSpeed( ) returns long
Used to retrieve the time it took to open the database connection (in milliseconds)
getDatabase( ) returns javaxt.sql.Database
Used to return database information associated with this connection.
getRecordset( String sql ) returns javaxt.utils.Generator
Used to execute a SQL statement and returns a Recordset as an iterator. The Recordset is read-only. Use the other getRecordset() method for creating and updating records.
getRecordset( String sql, boolean readOnly ) returns javaxt.utils.Generator
Used to execute a SQL statement and returns a Recordset as an iterator. This simplifies using the Recordset object insofar as it eliminate the need to call the hasNext(), moveNext(), and close() methods. Instead, you can execute a query and iterate through records like this:
        Connection conn = db.getConnection();
        for (Recordset rs : conn.getRecordset("select distinct(name) from contacts")){
            System.out.println(rs.getValue(0));
        }
        conn.close();
    
isClosed( ) returns boolean
Used to determine whether the connection is closed.
isOpen( ) returns boolean
Used to determine whether the connection is open.
open( String ConnectionString ) returns boolean
Used to open a connection to the database.
ConnectionStringA jdbc connection string/url. All connection URLs have the following form:
 jdbc:[dbVendor]://[dbName][propertyList] 
Example:
 jdbc:derby://temp/my.db;user=admin;password=mypassword 
open( javaxt.sql.Database database ) returns boolean
Used to open a connection to the database.
open( java.sql.Connection conn ) returns boolean
Used to open a connection to the database using a JDBC Connection. This is particularly useful when using JDBC connection pools.