i-net OPTA 2000

com.inet.tds
Class TdsDataSource

java.lang.Object
  |
  +--com.inet.tds.TdsDriver
        |
        +--com.inet.tds.TdsDataSource
All Implemented Interfaces:
java.lang.Cloneable, javax.sql.DataSource, java.sql.Driver, javax.naming.Referenceable, java.lang.Runnable, java.io.Serializable
Direct Known Subclasses:
DTCDataSource, PDataSource, XDataSource

public class TdsDataSource
extends com.inet.tds.TdsDriver
implements javax.sql.DataSource, java.io.Serializable, java.lang.Cloneable, javax.naming.Referenceable

This class is an implementation of a simple DataSource for the driver i-net OPTA(tm).

See Also:
Serialized Form

Field Summary
static int MODE_SQLSERVER_65
          SQL Server 6.5 compatible mode.
static int MODE_SQLSERVER_70
          SQL Server 7.0 or higher mode.
static int MODE_SQLSERVER_70_ASCII
          SQL Server 7.0 ASCII or higher mode.
 
Constructor Summary
TdsDataSource()
          Attempt to create a Datasource.
TdsDataSource(java.util.Properties info)
          Attempt to create a Datasource with the given properties.
 
Method Summary
 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.lang.String getCharset()
          Return the charset for the connection.
 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 getInstanceName()
          Return the instance name of the MS SQL Server.
 int getLoginTimeout()
          Returns the timeout for login.
 java.io.PrintWriter getLogWriter()
           
 int getMode()
          Get the protocol mode of the driver.
 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.
 boolean getSqlServer7Mode()
          Deprecated. See setMode
 boolean getUseCursorsAlways()
          Get the flag useCursorsAlways of the driver.
 java.lang.String getUser()
          Return the user for the connection.
 void setCharset(java.lang.String charset)
          Set the charset 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 setInstanceName(java.lang.String serverName)
          Set the instance name of the MS SQL Server.
 void setLoginTimeout(int seconds)
          Set the login timeout for the connection.
 void setLogWriter(java.io.PrintWriter out)
           
 void setMode(int mode)
          Set the protocol mode of the driver.
 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 setSqlServer7Mode(boolean mode)
          Deprecated. See setMode
 void setUseCursorsAlways(boolean mode)
          Set the flag useCursorsAlways of the driver.
 void setUser(java.lang.String user)
          Set the user account for the connection.
 java.lang.String toString()
           
 
Methods inherited from class com.inet.tds.TdsDriver
acceptsURL, connect, getMajorVersion, getMinorVersion, getPropertyInfo, jdbcCompliant, run
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MODE_SQLSERVER_65

public static final int MODE_SQLSERVER_65
SQL Server 6.5 compatible mode. This is equals to the JDBC subprotocol inetdae6. In config files you can use the value 65.

MODE_SQLSERVER_70

public static final int MODE_SQLSERVER_70
SQL Server 7.0 or higher mode. This is equals to the JDBC subprotocol inetdae7. The driver uses the unicode data types nXXX in PreparedStatements. In config files you can use the value 70.

MODE_SQLSERVER_70_ASCII

public static final int MODE_SQLSERVER_70_ASCII
SQL Server 7.0 ASCII or higher mode. This is equals to the JDBC subprotocol inetdae7. The driver uses the ASCII data types varchar, char and text in PreparedStatements. In config files you can use the value 71.
Constructor Detail

TdsDataSource

public TdsDataSource()
Attempt to create a Datasource. The default mode is to connect to the MS SQL Server 7 or higher.

TdsDataSource

public TdsDataSource(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
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.

getInstanceName

public java.lang.String getInstanceName()
Return the instance name of the MS SQL Server. This is a feature of the SQL Server 2000 or higher.
Returns:
instance name.
Since:
4.14

setInstanceName

public void setInstanceName(java.lang.String serverName)
Set the instance name of the MS SQL Server. This is a feature of the SQL Server 2000 or higher.
Parameters:
instance - name.
Since:
4.14

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.

getCharset

public java.lang.String getCharset()
Return the charset for the connection.
Returns:
the charset. If not set the value is null.

setCharset

public void setCharset(java.lang.String charset)
Set the charset for the connection.
Parameters:
charset - the charset for the MS SQL Server.

getLogWriter

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

setLogWriter

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

getLoginTimeout

public int getLoginTimeout()
Returns the timeout for login.
Specified by:
getLoginTimeout in interface javax.sql.DataSource
Returns:
the login timeout. If not set the value is 0.

setLoginTimeout

public void setLoginTimeout(int seconds)
Set the login timeout for the connection. This timeout * 5 is also the default query timeout for all statements.
Specified by:
setLoginTimeout in interface javax.sql.DataSource
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.
Parameters:
name - The name of the property.
value - The value of the property.
See Also:
getProperty(String), getProperties()

getProperties

public java.util.Properties getProperties()
Get all properties 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), getProperty(String)

setMode

public void setMode(int mode)
Set the protocol mode of the driver. The default value is MODE_SQLSERVER_70.
With the value MODE_SQLSERVER_65 you can connect to all SQL Server versions.
With the value MODE_SQLSERVER_70 you can only connect to SQL Server 7.0 or higher.
Parameters:
mode - the protocol mode
See Also:
getMode(), MODE_SQLSERVER_65, MODE_SQLSERVER_70, MODE_SQLSERVER_70_ASCII

getMode

public int getMode()
Get the protocol mode of the driver.
Returns:
the protocol mode
See Also:
setMode(int), MODE_SQLSERVER_65, MODE_SQLSERVER_70, MODE_SQLSERVER_70_ASCII

setSqlServer7Mode

public void setSqlServer7Mode(boolean mode)
Deprecated. See setMode

Set the protocol mode of the driver. The default value is true. With the value false you can connect to all SQL Server versions. With the value true you can only connect to SQL Server 7.0 or higher.
Parameters:
mode - the protocol mode
See Also:
getSqlServer7Mode(), setMode(int)

getSqlServer7Mode

public boolean getSqlServer7Mode()
Deprecated. See setMode

Get the protocol mode of the driver.
Returns:
the protocol mode
See Also:
setSqlServer7Mode(boolean)

setUseCursorsAlways

public void setUseCursorsAlways(boolean mode)
Set the flag useCursorsAlways of the driver.
See Also:
getUseCursorsAlways()

getUseCursorsAlways

public boolean getUseCursorsAlways()
Get the flag useCursorsAlways of the driver.
Returns:
the flag useCursorsAlways
See Also:
setUseCursorsAlways(boolean)

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Create a new object of the same class like this DataSource.
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 TdsDataSource object that has the same significant properties.
Overrides:
equals in class java.lang.Object
Parameters:
obj - the object to compare.

getReference

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

toString

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

i-net OPTA 2000


copyright by i-net software