org.geotools.data.mysql
Class MysqlConnection

java.lang.Object
  extended byorg.geotools.data.mysql.MysqlConnection
All Implemented Interfaces:
javax.sql.DataSource

public class MysqlConnection
extends java.lang.Object
implements javax.sql.DataSource

Shell for JDBC transactions of all types. This provides a base class to the database transactional classes.

Version:
$Id: MysqlConnection.java 17700 2006-01-22 23:30:39Z desruisseaux $
Author:
Rob Hranac, Vision for New York, Chris Holmes, Vision for New York

Constructor Summary
MysqlConnection(java.lang.String host, java.lang.String port, java.lang.String dbName)
          Constructor with all internal database driver classes, driver paths and database types.
 
Method Summary
 java.sql.Connection getConnection()
          Retrieves a connection to the Mysql database, using the current user and password;
 java.sql.Connection getConnection(java.lang.String user, java.lang.String password)
          Retrieves a connection to the Mysql database, specifying a user and password.
 java.lang.String getLoginPassword()
          An accessor function to get the password to log in to the db.
 int getLoginTimeout()
          An accessor function to get the length of timeout.
 java.lang.String getLoginUser()
          An accessor function to get the user to log in to the db.
 java.io.PrintWriter getLogWriter()
          An accessor function to get the log writer.
 void setLogin(java.lang.String user, java.lang.String password)
          Sets the user and password strings of the login to be used when connecting to the Mysql database.
 void setLoginTimeout(int seconds)
          A setter function to get the length of timeout.
 void setLogWriter(java.io.PrintWriter out)
          An setter method to set the log writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MysqlConnection

public MysqlConnection(java.lang.String host,
                       java.lang.String port,
                       java.lang.String dbName)
Constructor with all internal database driver classes, driver paths and database types.

Parameters:
host - The driver class; should be passed from the database-specific subclass.
port - The driver path; should be passed from the database-specific subclass.
dbName - The database type; should be passed from the database-specific subclass.
Method Detail

setLogin

public void setLogin(java.lang.String user,
                     java.lang.String password)
Sets the user and password strings of the login to be used when connecting to the Mysql database.

Parameters:
user - The string of the user to connect to the database with.
password - The string of the password of user.

getLoginUser

public java.lang.String getLoginUser()
An accessor function to get the user to log in to the db.

Returns:
the user.

getLoginPassword

public java.lang.String getLoginPassword()
An accessor function to get the password to log in to the db.

Returns:
a string of the password.

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
Retrieves a connection to the Mysql database, using the current user and password;

Specified by:
getConnection in interface javax.sql.DataSource
Returns:
An open SQL connection with the database.
Throws:
java.sql.SQLException - if there are any database problems.

getConnection

public java.sql.Connection getConnection(java.lang.String user,
                                         java.lang.String password)
                                  throws java.sql.SQLException
Retrieves a connection to the Mysql database, specifying a user and password.

Specified by:
getConnection in interface javax.sql.DataSource
Parameters:
user - The string of the user to connect to the database with.
password - The string of the corresponding password of user.
Returns:
An open SQL connection with the database.
Throws:
java.sql.SQLException - if there are any database problems.

getLoginTimeout

public int getLoginTimeout()
An accessor function to get the length of timeout.

Specified by:
getLoginTimeout in interface javax.sql.DataSource
Returns:
the time out.
Task:
TODO: implement this.

setLoginTimeout

public void setLoginTimeout(int seconds)
A setter function to get the length of timeout.

Specified by:
setLoginTimeout in interface javax.sql.DataSource
Parameters:
seconds - the length of the time out.
Task:
TODO: implement this.

getLogWriter

public java.io.PrintWriter getLogWriter()
An accessor function to get the log writer.

Specified by:
getLogWriter in interface javax.sql.DataSource
Returns:
a writer
Task:
TODO: implement this.

setLogWriter

public void setLogWriter(java.io.PrintWriter out)
An setter method to set the log writer.

Specified by:
setLogWriter in interface javax.sql.DataSource
Parameters:
out - the writer to use for logging.
Task:
TODO: implement this.


Copyright © GeoTools. All Rights Reserved.