JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.datasource.jdbc
Class DataTableConnection

java.lang.Object
  |
  +--com.klg.jclass.datasource.jdbc.DataTableConnection
All Implemented Interfaces:
Serializable

public class DataTableConnection
extends Object
implements Serializable

A connection to a JDBC datasource. It can be shared between various data controls.

See Also:
Serialized Form

Field Summary
protected  boolean autoCommitFlag
           
protected  Connection connection
           
 
Constructor Summary
DataTableConnection()
          DataTableConnection Constructor, empty, must load driver and call connect after instantiating.
DataTableConnection(String driver, String url, String user, String password, String database)
          DataTableConnection Constructor.
 
Method Summary
 void connect(String url, Properties properties)
          Establish a connection using property object.
 void connect(String url, String login, String password)
          Establish a connection to a data database using odbc style.
 void connect(String url, String login, String password, String db)
          Establish a connection to a data database using hostname and port.
 void disconnect()
          Close the connection to the database.
 boolean getAutoCommit()
          Get auto commit value.
 Connection getConnection()
          Return this connection to the database.
 void loadDriver(String driver)
          Load this driver into memory.
 void reconnect()
          Reconnect using previous parameters.
 void setAutoCommit(boolean value)
          Set auto commit value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

connection

protected transient Connection connection

autoCommitFlag

protected boolean autoCommitFlag
Constructor Detail

DataTableConnection

public DataTableConnection(String driver,
                           String url,
                           String user,
                           String password,
                           String database)
                    throws DataModelException
DataTableConnection Constructor.

Parameters:
driver - a String indicating which driver to load
url - a String url for the connection
user - a String for the user name
password - a String for the user password
database - a String for the data base name
Throws:
DataModelException - If initialization fails.

DataTableConnection

public DataTableConnection()
DataTableConnection Constructor, empty, must load driver and call connect after instantiating.

Method Detail

loadDriver

public void loadDriver(String driver)
                throws DataModelException
Load this driver into memory.

Parameters:
driver - a String indicating which driver to load
Throws:
DataModelException - If driver fails to load.

connect

public void connect(String url,
                    String login,
                    String password,
                    String db)
             throws DataModelException
Establish a connection to a data database using hostname and port.

Parameters:
url - a String url for the connection
login - a String for the user name
password - a String for the user password
db - a String for the data base name
Throws:
DataModelException - If connection fails.

connect

public void connect(String url,
                    String login,
                    String password)
             throws DataModelException
Establish a connection to a data database using odbc style.

Parameters:
url - a String url for the connection
login - a String for the user name
password - a String for the user password
Throws:
DataModelException - If connection fails.

connect

public void connect(String url,
                    Properties properties)
             throws DataModelException
Establish a connection using property object. For example,

  Properties props = new Properties();
  props.put("user", "dba");
  props.put("password", "90210");
  c = new DataTableConnection();
  c.loadDriver("sun.jdbc.odbc.JdbcOdbcDriver");
  c.connect("jdbc:odbc:JClassDemoSQLAnywhere", props);
 

Parameters:
url - a String a database url of the form jdbc:subprotocol:subname
properties - a list of arbitrary string tag/value pairs as connection arguments; normally at least a "user" and "password" property should be included
Throws:
DataModelException - If connection fails.

getConnection

public Connection getConnection()
Return this connection to the database.

Returns:
a JDBC Connection

disconnect

public void disconnect()
Close the connection to the database.


reconnect

public void reconnect()
               throws DataModelException
Reconnect using previous parameters.

Throws:
DataModelException - If reconnect fails.

setAutoCommit

public void setAutoCommit(boolean value)
                   throws SQLException
Set auto commit value. Determines whether to automatically commit uncommited changes to the * data source when the current row changes (true), or wait until commit is called manually (false).

Parameters:
value - a boolean determining when the commit occurs.
Throws:
SQLException - If data base access error occurs.

getAutoCommit

public boolean getAutoCommit()
                      throws SQLException
Get auto commit value. Determines whether to automatically commit uncommited changes to the * data source when the current row changes (true), or wait until commit is called manually (false). Default is true.

Returns:
a boolean determining when the commit occurs.
Throws:
SQLException - If data base access error occurs.

Copyright © 2004 Quest Software Inc..
All rights reserved.