org.jdesktop.dataset.provider.sql
Class JDBCDataConnection

java.lang.Object
  extended by org.jdesktop.dataset.DataConnection
      extended by org.jdesktop.dataset.provider.sql.JDBCDataConnection

public class JDBCDataConnection
extends DataConnection

An implementation of the DataConnection for interacting with a local database. This implementation is "local", meaning that it is written and optimized for low latency database access, such as for an in memory database, or one on a local network.

Author:
rbair

Constructor Summary
JDBCDataConnection()
          Create a new DatabaseDataStoreConnection.
JDBCDataConnection(java.lang.String driver, java.lang.String url, java.util.Properties props)
          Create a new JDBCDataConnection and initializes it to connect to a database using the given params.
JDBCDataConnection(java.lang.String jndiContext, java.lang.String user, java.lang.String passwd)
          Create a new JDBCDataConnection and initializes it to connect to a database using the given params.
JDBCDataConnection(java.lang.String driver, java.lang.String url, java.lang.String user, java.lang.String passwd)
          Create a new JDBCDataConnection and initializes it to connect to a database using the given params.
 
Method Summary
 void commit()
           
protected  void connect()
          Connect to the database.
protected  void disconnect()
          Disconnects from the database and causes all of the attached DataModels to flush their contents.
 java.sql.ResultSet executeQuery(java.sql.PreparedStatement ps)
           
 int executeUpdate(java.sql.PreparedStatement ps)
           
 java.sql.Connection getConnection()
           
 java.lang.String getPassword()
           
 java.util.Properties getProperties()
           
 java.lang.String getUrl()
           
 java.lang.String getUserName()
           
 java.sql.PreparedStatement prepareStatement(java.lang.String sql)
           
 void setPassword(java.lang.String password)
           
 void setProperties(java.util.Properties properties)
           
 void setUrl(java.lang.String url)
           
 void setUserName(java.lang.String userName)
           
 
Methods inherited from class org.jdesktop.dataset.DataConnection
addPropertyChangeListener, addPropertyChangeListener, isConnected, removePropertyChangeListener, setConnected
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JDBCDataConnection

public JDBCDataConnection()
Create a new DatabaseDataStoreConnection. Be sure to set the JDBC connection properties (user name, password, connection method, etc) prior to connecting this object.


JDBCDataConnection

public JDBCDataConnection(java.lang.String driver,
                          java.lang.String url,
                          java.lang.String user,
                          java.lang.String passwd)
Create a new JDBCDataConnection and initializes it to connect to a database using the given params.

Parameters:
driver -
url -
user -
passwd -

JDBCDataConnection

public JDBCDataConnection(java.lang.String driver,
                          java.lang.String url,
                          java.util.Properties props)
Create a new JDBCDataConnection and initializes it to connect to a database using the given params.

Parameters:
driver -
url -
props -

JDBCDataConnection

public JDBCDataConnection(java.lang.String jndiContext,
                          java.lang.String user,
                          java.lang.String passwd)
Create a new JDBCDataConnection and initializes it to connect to a database using the given params.

Parameters:
jndiContext -
user -
passwd -
Method Detail

getUrl

public java.lang.String getUrl()
Returns:
the JDBC connection url

setUrl

public void setUrl(java.lang.String url)
Parameters:
url - set the JDBC connection url

getUserName

public java.lang.String getUserName()
Returns:
the user name used to connect to the database

setUserName

public void setUserName(java.lang.String userName)
Parameters:
userName - used to connect to the database

getPassword

public java.lang.String getPassword()
Returns:
the password used to connect to the database

setPassword

public void setPassword(java.lang.String password)
Parameters:
password - the password used to connect to the database

getProperties

public java.util.Properties getProperties()
Returns:
JDBC connection properties

setProperties

public void setProperties(java.util.Properties properties)
Parameters:
properties - miscellaneous JDBC properties to use when connecting to the database via the JDBC driver

connect

protected void connect()
                throws java.lang.Exception
Connect to the database. This method attempts to connect via jndiContext first, if possible. If not, then it tries to connect by using the DriverManager.

Specified by:
connect in class DataConnection
Throws:
java.lang.Exception

disconnect

protected void disconnect()
                   throws java.lang.Exception
Disconnects from the database and causes all of the attached DataModels to flush their contents.

Specified by:
disconnect in class DataConnection
Throws:
java.lang.Exception

executeQuery

public java.sql.ResultSet executeQuery(java.sql.PreparedStatement ps)

executeUpdate

public int executeUpdate(java.sql.PreparedStatement ps)

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String sql)
                                            throws java.lang.Exception
Throws:
java.lang.Exception

commit

public void commit()

getConnection

public java.sql.Connection getConnection()


Copyright © 2005 Sun Microsystems All Rights Reserved.