i-net DB2 drivers

com.inet.drda
Class DRDADataSource

java.lang.Object
  extended by com.inet.drda.DRDADataSource
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.sql.Wrapper, javax.naming.Referenceable, javax.sql.CommonDataSource, javax.sql.DataSource
Direct Known Subclasses:
PDataSource

public class DRDADataSource
extends java.lang.Object
implements javax.sql.DataSource, java.io.Serializable, java.lang.Cloneable, javax.naming.Referenceable

This class is an implementation of a simple DataSource.

See Also:
Serialized Form

Constructor Summary
DRDADataSource()
          Attempt to create a Datasource.
DRDADataSource(java.util.Properties info)
          Attempt to create a Datasource with the given properties.
 
Method Summary
 void addWarning(java.sql.SQLWarning warning)
           
 java.lang.Object clone()
          Create a new object of the same class like this DataSource.
 boolean equals(java.lang.Object obj)
          Compare this DataSource to the specified object.
 java.sql.Connection getConnection()
          Attempt to establish a connection to the database.
 java.sql.Connection getConnection(java.lang.String username, java.lang.String password)
          Attempt to establish a connection to the database.
 java.lang.String getDatabaseName()
          Return the first database name of the connection after login.
 java.lang.String getDescription()
          Return a one line description of the DataSource.
 java.lang.String getInitSQL()
          Get the init SQL expresion.
 int getLoginTimeout()
          Returns the timeout for login.
 java.io.PrintWriter getLogWriter()
           
 java.lang.String getPassword()
          Return the password for the connection.
 java.lang.String getPort()
          Return the TCP/IP port number of the MS SQL Server.
 int getPortNumber()
          Return the TCP/IP port number of the MS SQL Server.
 java.util.Properties getProperties()
          Get all properties of the DataSource without LoginTimeout and LogWriter.
 java.lang.String getProperty(java.lang.String name)
          Get any property of the DataSource without LoginTimeout and LogWriter.
 int getQueryTimeout()
          Returns the default query timeout for all statements.
 javax.naming.Reference getReference()
           
 java.lang.String getServerName()
          Return the server name of the MS SQL Server.
 java.lang.String getUser()
          Return the user for the connection.
 void setDatabaseName(java.lang.String databaseName)
          Set the first database name of the connection after login.
 void setDescription(java.lang.String description)
          Set the description of the DataSource.
 void setInitSQL(java.lang.String initSQL)
          Set the init SQL expresion.
 void setLoginTimeout(int seconds)
          Set the login timeout for the connection. 5 is also the default query timeout for all statements.
 void setLogWriter(java.io.PrintWriter out)
           
 void setPassword(java.lang.String password)
          Set the password for the connection.
 void setPort(java.lang.String port)
          Set TCP/IP port number of the MS SQL Server.
 void setPortNumber(int portNumber)
          Set TCP/IP port number of the MS SQL Server.
 void setProperties(java.util.Properties properties)
          Set all properties of the DataSource without LoginTimeout and LogWriter.
 void setProperty(java.lang.String name, java.lang.Object value)
          Set any property of the DataSource without LogWriter.
 void setProperty(java.lang.String name, java.lang.String value)
          Set any property of the DataSource without LogWriter.
 void setQueryTimeout(int seconds)
          Set the default query timeout for all statements.
 void setServerName(java.lang.String serverName)
          Set the server name of the MS SQL Server.
 void setUser(java.lang.String user)
          Set the user account for the connection.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.sql.Wrapper
isWrapperFor, unwrap
 

Constructor Detail

DRDADataSource

public DRDADataSource()
               throws java.sql.SQLException
Attempt to create a Datasource.

Throws:
java.sql.SQLException

DRDADataSource

public DRDADataSource(java.util.Properties info)
               throws java.sql.SQLException
Attempt to create a Datasource with the given properties.

Parameters:
info - a list of arbitrary string tag/value pairs as connection arguments; normally at least a "user" and "password" property should be included
Throws:
java.sql.SQLException
Method Detail

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
Attempt to establish a connection to the database.

Specified by:
getConnection in interface javax.sql.DataSource
Returns:
a Connection to the database.
Throws:
java.sql.SQLException

getConnection

public java.sql.Connection getConnection(java.lang.String username,
                                         java.lang.String password)
                                  throws java.sql.SQLException
Attempt to establish a connection to the database.

Specified by:
getConnection in interface javax.sql.DataSource
Parameters:
username - the database user on whose behalf the Connection is being made.
password - the user's password.
Returns:
a Connection to the database.
Throws:
java.sql.SQLException

getServerName

public java.lang.String getServerName()
Return the server name of the MS SQL Server.

Returns:
the host name or IP-Address. If not set the value is null.

setServerName

public void setServerName(java.lang.String serverName)
Set the server name of the MS SQL Server.

Parameters:
serverName - the host name or IP-Address.

getDatabaseName

public java.lang.String getDatabaseName()
Return the first database name of the connection after login. If not set the user default database is used.

Returns:
the name of database. If not set the value is null.

setDatabaseName

public void setDatabaseName(java.lang.String databaseName)
Set the first database name of the connection after login.

Parameters:
databaseName - the name of database.

getDescription

public java.lang.String getDescription()
Return a one line description of the DataSource.

Returns:
the description. If not set the value is null.

setDescription

public void setDescription(java.lang.String description)
Set the description of the DataSource.

Parameters:
description - a one line description.

getPortNumber

public int getPortNumber()
Return the TCP/IP port number of the MS SQL Server.

Returns:
the port number. If not set the value is 1433.

getPort

public java.lang.String getPort()
Return the TCP/IP port number of the MS SQL Server.

Returns:
the port number. If not set the value will be 1433.

setPortNumber

public void setPortNumber(int portNumber)
Set TCP/IP port number of the MS SQL Server. If not set the default value of 1433 will be used.

Parameters:
portNumber - the port number.

setPort

public void setPort(java.lang.String port)
Set TCP/IP port number of the MS SQL Server. If not set the default value of 1433 will be used.

Parameters:
port - the port number.

getPassword

public java.lang.String getPassword()
Return the password for the connection.

Returns:
the password. If not set the value is null.

setPassword

public void setPassword(java.lang.String password)
Set the password for the connection. If not set an empty password is used. It must be the password of a MS SQL Server login and not the password of a NT Account.

Parameters:
password - the password for the MS SQL Server.

getUser

public java.lang.String getUser()
Return the user for the connection.

Returns:
the user. If not set the value is null.

setUser

public void setUser(java.lang.String user)
Set the user account for the connection. This account must be set. It must be a user name of a MS SQL Server login and not the user name of a NT Account.

Parameters:
user - the user for the MS SQL Server.

getLogWriter

public java.io.PrintWriter getLogWriter()
Specified by:
getLogWriter in interface javax.sql.CommonDataSource

setLogWriter

public void setLogWriter(java.io.PrintWriter out)
Specified by:
setLogWriter in interface javax.sql.CommonDataSource

getLoginTimeout

public int getLoginTimeout()
Returns the timeout for login.

Specified by:
getLoginTimeout in interface javax.sql.CommonDataSource
Returns:
the login timeout. If not set the value is 0.

setLoginTimeout

public void setLoginTimeout(int seconds)
Set the login timeout for the connection. 5 is also the default query timeout for all statements.

Specified by:
setLoginTimeout in interface javax.sql.CommonDataSource
Parameters:
seconds - the login timeout for the connection.

getQueryTimeout

public int getQueryTimeout()
Returns the default query timeout for all statements.

Returns:
the query timeout. If not set the value is 0.

setQueryTimeout

public void setQueryTimeout(int seconds)
Set the default query timeout for all statements.

Parameters:
seconds - the query timeout

setProperty

public void setProperty(java.lang.String name,
                        java.lang.String value)
Set any property of the DataSource without LogWriter.

Parameters:
name - The name of the property.
value - The value of the property.
See Also:
getProperty(String), getProperties()

setProperty

public void setProperty(java.lang.String name,
                        java.lang.Object value)
Set any property of the DataSource without LogWriter. This method was used from WebLogic Server

Parameters:
name - The name of the property.
value - The value of the property.
See Also:
getProperty(String), getProperties()

getProperty

public java.lang.String getProperty(java.lang.String name)
Get any property of the DataSource without LoginTimeout and LogWriter.

Parameters:
name - The name of the property.
Returns:
value The value of the property.
See Also:
setProperty(String,String), getProperties()

setProperties

public void setProperties(java.util.Properties properties)
Set all properties of the DataSource without LoginTimeout and LogWriter.

See Also:
getProperty(String), getProperties()

getProperties

public java.util.Properties getProperties()
Get all properties of the DataSource without LoginTimeout and LogWriter.

Returns:
value The value of the property.
See Also:
setProperty(String,String), getProperty(String)

setInitSQL

public void setInitSQL(java.lang.String initSQL)
Set the init SQL expresion. This expression is executed once per connection.

See Also:
getInitSQL()

getInitSQL

public java.lang.String getInitSQL()
Get the init SQL expresion.

See Also:
setInitSQL(java.lang.String)

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Create a new object of the same class like this DataSource.

Overrides:
clone in class java.lang.Object
Returns:
a clone of this instance.
Throws:
java.lang.CloneNotSupportedException

equals

public boolean equals(java.lang.Object obj)
Compare this DataSource to the specified object. The result is true if and only if the argument is not null and is a DataSource object that has the same significant properties.

Overrides:
equals in class java.lang.Object
Parameters:
obj - the object to compare.

addWarning

public void addWarning(java.sql.SQLWarning warning)
                throws java.sql.SQLException
Throws:
java.sql.SQLException

getReference

public javax.naming.Reference getReference()
                                    throws javax.naming.NamingException
Specified by:
getReference in interface javax.naming.Referenceable
Throws:
javax.naming.NamingException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

i-net DB2 drivers


copyright by i-net software