org.firebirdsql.pool
Class FBSimpleDataSource

java.lang.Object
  extended byorg.firebirdsql.pool.FBSimpleDataSource
All Implemented Interfaces:
javax.sql.DataSource, javax.resource.Referenceable, javax.naming.Referenceable, java.io.Serializable

public class FBSimpleDataSource
extends java.lang.Object
implements javax.sql.DataSource, java.io.Serializable, javax.resource.Referenceable

This is a simple implementation of DataSource interface. Connections are physically opened in DataSource.getConnection() method and physically closed in Connection.close() method. If you need connection pooling, use FBWrappingDataSource instead.

Version:
1.0
Author:
Roman Rokytskyy, David Jencks
See Also:
Serialized Form

Field Summary
protected  java.lang.String description
           
protected  FBDataSource ds
           
protected  javax.naming.Reference jndiReference
           
protected  java.io.PrintWriter log
           
protected  int loginTimeout
           
protected  FBManagedConnectionFactory mcf
           
protected  java.lang.String tpbMapping
           
 
Constructor Summary
FBSimpleDataSource()
          Create instance of this class.
FBSimpleDataSource(GDSType type)
          Create instance of this class.
 
Method Summary
 java.lang.Integer getBlobBufferLength()
          Get buffer length for the BLOB fields.
 java.sql.Connection getConnection()
          Get JDBC connection with default credentials.
 java.sql.Connection getConnection(java.lang.String username, java.lang.String password)
          Get JDBC connection with the specified credentials.
 java.lang.String getDatabase()
          Get name of the database.
 java.lang.String getDatabaseName()
          Deprecated. use getDatabase() instead for the sake of naming compatibility.
protected  javax.sql.DataSource getDataSource()
          Get underlying connection factory (in our case instance of FBDataSource class) that will provide JDBC connections.
 java.lang.String getDescription()
          Get description of this datasource.
 java.lang.String getEncoding()
          Get encoding for connections produced by this data source.
 int getLoginTimeout()
          Get login timeout specified for this datasource.
 java.io.PrintWriter getLogWriter()
          Get log for this datasource.
 java.lang.String getPassword()
          Get password used in getConnection() method.
 javax.naming.Reference getReference()
          Get previously set JNDI reference.
 java.lang.String getTpbMapping()
           
 java.lang.String getUser()
          Deprecated. use getUserName() instead for the sake of naming compatibility.
 java.lang.String getUserName()
          Get user name that is used in getConnection() method.
 void setBlobBufferLength(java.lang.Integer length)
          Set BLOB buffer length.
 void setDatabase(java.lang.String name)
          Set database name.
 void setDatabaseName(java.lang.String name)
          Deprecated. use setDatabase(String) instead for the sake of naming compatibility.
 void setDescription(java.lang.String description)
          Set description of this datasource.
 void setEncoding(java.lang.String encoding)
          Set encoding for connections produced by this data source.
 void setLoginTimeout(int loginTimeout)
          Set login timeout for this datasource.
 void setLogWriter(java.io.PrintWriter log)
          Set log for this datasource.
 void setPassword(java.lang.String password)
          Set password that will be used in the getConnection() method.
 void setReference(javax.naming.Reference reference)
          Set JNDI reference for this data source.
 void setTpbMapping(java.lang.String tpbMapping)
           
 void setUser(java.lang.String user)
          Deprecated. use setUserName(String) instead for the sake of naming compatibility.
 void setUserName(java.lang.String userName)
          Set user name that will be used in getConnection() method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mcf

protected transient FBManagedConnectionFactory mcf

ds

protected transient FBDataSource ds

log

protected transient java.io.PrintWriter log

jndiReference

protected javax.naming.Reference jndiReference

description

protected java.lang.String description

loginTimeout

protected int loginTimeout

tpbMapping

protected java.lang.String tpbMapping
Constructor Detail

FBSimpleDataSource

public FBSimpleDataSource()
Create instance of this class.


FBSimpleDataSource

public FBSimpleDataSource(GDSType type)
Create instance of this class.

Method Detail

getBlobBufferLength

public java.lang.Integer getBlobBufferLength()
Get buffer length for the BLOB fields.

Returns:
length of BLOB buffer.

setBlobBufferLength

public void setBlobBufferLength(java.lang.Integer length)
Set BLOB buffer length. This value influences the performance when working with BLOB fields.

Parameters:
length - new length of the BLOB buffer.

getDatabaseName

public java.lang.String getDatabaseName()
Deprecated. use getDatabase() instead for the sake of naming compatibility.

Get name of the database.

Returns:
database name, value is equal to the part of full JDBC URL without the jdbc:firebirdsql: part.

setDatabaseName

public void setDatabaseName(java.lang.String name)
Deprecated. use setDatabase(String) instead for the sake of naming compatibility.

Set database name.

Parameters:
name - connection URL without "jdbc:firebirdsql:" prefix ("//localhost:3050/c:/database/employee.gdb") for example).

getDatabase

public java.lang.String getDatabase()
Get name of the database.

Returns:
database name, value is equal to the part of full JDBC URL without the jdbc:firebirdsql: part.

setDatabase

public void setDatabase(java.lang.String name)
Set database name.

Parameters:
name - connection URL without "jdbc:firebirdsql:" prefix ("//localhost:3050/c:/database/employee.gdb") for example).

getUser

public java.lang.String getUser()
Deprecated. use getUserName() instead for the sake of naming compatibility.

Get user name that is used in getConnection() method.

Returns:
default user name.

setUser

public void setUser(java.lang.String user)
Deprecated. use setUserName(String) instead for the sake of naming compatibility.

Set user name that will be used in getConnection() method.

Parameters:
user - default user name.

getUserName

public java.lang.String getUserName()
Get user name that is used in getConnection() method.

Returns:
default user name.

setUserName

public void setUserName(java.lang.String userName)
Set user name that will be used in getConnection() method.

Parameters:
userName - default user name.

getPassword

public java.lang.String getPassword()
Get password used in getConnection() method.

Returns:
password corresponding to the user name returned by getUserName().

setPassword

public void setPassword(java.lang.String password)
Set password that will be used in the getConnection() method.

Parameters:
password - password corresponding to the user name set in setUserName(String).

getEncoding

public java.lang.String getEncoding()
Get encoding for connections produced by this data source.

Returns:
encoding for the connection.

setEncoding

public void setEncoding(java.lang.String encoding)
Set encoding for connections produced by this data source.

Parameters:
encoding - encoding for the connection.

getTpbMapping

public java.lang.String getTpbMapping()

setTpbMapping

public void setTpbMapping(java.lang.String tpbMapping)
                   throws FBResourceException
Throws:
FBResourceException

getReference

public javax.naming.Reference getReference()
                                    throws javax.naming.NamingException
Get previously set JNDI reference.

Specified by:
getReference in interface javax.naming.Referenceable
Returns:
instance of Reference set previously.
Throws:
javax.naming.NamingException - if something went wrong.

setReference

public void setReference(javax.naming.Reference reference)
Set JNDI reference for this data source.

Specified by:
setReference in interface javax.resource.Referenceable
Parameters:
reference - reference to set.

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
Get JDBC connection with default credentials.

Specified by:
getConnection in interface javax.sql.DataSource
Returns:
new JDBC connection.
Throws:
java.sql.SQLException - if something went wrong.

getConnection

public java.sql.Connection getConnection(java.lang.String username,
                                         java.lang.String password)
                                  throws java.sql.SQLException
Get JDBC connection with the specified credentials.

Specified by:
getConnection in interface javax.sql.DataSource
Parameters:
username - user name for the connection.
password - password for the connection.
Returns:
new JDBC connection.
Throws:
java.sql.SQLException - if something went wrong.

getLogWriter

public java.io.PrintWriter getLogWriter()
                                 throws java.sql.SQLException
Get log for this datasource.

Specified by:
getLogWriter in interface javax.sql.DataSource
Returns:
log associated with this datasource.
Throws:
java.sql.SQLException - if something went wrong.

setLogWriter

public void setLogWriter(java.io.PrintWriter log)
                  throws java.sql.SQLException
Set log for this datasource.

Specified by:
setLogWriter in interface javax.sql.DataSource
Parameters:
log - instance of PrintWriter that should be associated with this datasource.
Throws:
java.sql.SQLException - if something went wrong.

getLoginTimeout

public int getLoginTimeout()
                    throws java.sql.SQLException
Get login timeout specified for this datasource.

Specified by:
getLoginTimeout in interface javax.sql.DataSource
Returns:
login timeout of this datasource in seconds.
Throws:
java.sql.SQLException - if something went wrong.

setLoginTimeout

public void setLoginTimeout(int loginTimeout)
                     throws java.sql.SQLException
Set login timeout for this datasource.

Specified by:
setLoginTimeout in interface javax.sql.DataSource
Parameters:
loginTimeout - login timeout in seconds.
Throws:
java.sql.SQLException

getDescription

public java.lang.String getDescription()
Get description of this datasource.

Returns:
description of this datasource.

setDescription

public void setDescription(java.lang.String description)
Set description of this datasource.

Parameters:
description - description of this datasource.

getDataSource

protected javax.sql.DataSource getDataSource()
                                      throws java.sql.SQLException
Get underlying connection factory (in our case instance of FBDataSource class) that will provide JDBC connections.

Returns:
JDBC connection factory.
Throws:
java.sql.SQLException - if something went wrong.


Copyright © 2001 David Jencks and other authors. All rights reserved.