org.brains2b.sql
Class LocalConnector

java.lang.Object
  extended by org.brains2b.sql.LocalConnector
All Implemented Interfaces:
java.lang.Cloneable, Connector

public class LocalConnector
extends java.lang.Object
implements Connector

Implementation of Connector to connect to a local JDBC source, defined by the parameters passed in the constructor

Version:
1.0 [26-02-2007]
Author:
dennis@brains2b.nl

Field Summary
protected  java.sql.Driver m_driver
           
protected  java.util.Properties m_info
           
protected  java.lang.String m_url
           
 
Constructor Summary
protected LocalConnector()
          Constructor which does not initialize the connection properties.
  LocalConnector(java.lang.String driver, java.lang.String url, java.lang.String user, java.lang.String password)
          Constructor
  LocalConnector(java.lang.String classpath, java.lang.String driver, java.lang.String url, java.lang.String user, java.lang.String password)
          Constructor
 
Method Summary
 java.lang.Object clone()
          clone the connector object, not copying the connection itself.
 void close()
          close this connector and the contained connection
 java.sql.Connection getConnection()
          get the JDBC connection for this Connector
 java.lang.String getDbName()
          get the database name this connection uses.
 java.lang.String getServerName()
          get the name of the server this connection uses.
 java.lang.String getUser()
          Returns the name of the user this connection is using
protected  void init(java.lang.String classPath, java.lang.String driver, java.lang.String url, java.lang.String user, java.lang.String password)
          Initializes the parameters needed to make a connection.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_url

protected java.lang.String m_url

m_driver

protected java.sql.Driver m_driver

m_info

protected java.util.Properties m_info
Constructor Detail

LocalConnector

protected LocalConnector()
Constructor which does not initialize the connection properties.

Only used for overwriting this class as needed. Initialize the values yourself

See Also:
init(String, String, String, String, String)

LocalConnector

public LocalConnector(java.lang.String driver,
                      java.lang.String url,
                      java.lang.String user,
                      java.lang.String password)
Constructor

Requirement of the user and password parameters depends on the driver used. Set to null if not used.

Parameters:
driver - String, the classname of the driver to use. The class should be in the classpath
url, - the JDBC url describing which driver,server, port and database to use. See JDBC api description for syntax
user, - String the username to use for this connection
password, - String the password to use for this connection

LocalConnector

public LocalConnector(java.lang.String classpath,
                      java.lang.String driver,
                      java.lang.String url,
                      java.lang.String user,
                      java.lang.String password)
Constructor

Requirement of the user and password parameters depends on the driver used. Set to null if not used.

Parameters:
classpath - String, a semi-colon seperated list of jars and/or dirs containing the driver
driver - String, the classname of the driver to use. The class should be in the supplied classpath or the default classpath
url, - the JDBC url describing which driver,server, port and database to use. See JDBC api description for syntax
user, - String the username to use for this connection
password, - String the password to use for this connection
Method Detail

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
get the JDBC connection for this Connector

Specified by:
getConnection in interface Connector
Returns:
Connection
Throws:
java.sql.SQLException

close

public void close()
           throws java.sql.SQLException
close this connector and the contained connection

Specified by:
close in interface Connector
Throws:
java.sql.SQLException

init

protected void init(java.lang.String classPath,
                    java.lang.String driver,
                    java.lang.String url,
                    java.lang.String user,
                    java.lang.String password)
Initializes the parameters needed to make a connection.

Requirement of the user and password parameters depends on the driver used.

Parameters:
classpath - String, a semi-colon seperated list of jars and/or dirs containing the driver
driver - String, the classname of the driver to use. The class should be in the classpath
url, - the JDBC url describing which driver,server, port and database to use. See JDBC api description for syntax
user, - String the username to use for this connection
password, - String the password to use for this connection

getUser

public java.lang.String getUser()
Returns the name of the user this connection is using

Specified by:
getUser in interface Connector
Returns:
String, the name of the user

getDbName

public java.lang.String getDbName()
get the database name this connection uses.

Information is destilled from the url provided.

Returns:
String, the name of the database
Since:
Squeler 0.23

getServerName

public java.lang.String getServerName()
get the name of the server this connection uses.

Information is destilled from the url provided.

Returns:
String, the name of the server
Since:
Squeler 0.23

clone

public java.lang.Object clone()
clone the connector object, not copying the connection itself. Used of the clone connector will thus make a new connection to the database

Specified by:
clone in interface Connector
Overrides:
clone in class java.lang.Object
Returns: