All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.imaginary.sql.msql.MsqlDataSource

com.imaginary.sql.msql.MsqlDataSource

public class MsqlDataSource
JDBC 2.0 standard extension data source for JNDI access to an mSQL data source. Given a JNDI-accessible naming and directory service and a registered mSQL data source, client code can access that data source using JNDI calls. To access a database called "Wibbles", you would use the following code:
 Context ctx = new InitialContext();
 DataSource ds = (DataSource)ctx.lookup("jdbc/Wibbles");
 Connection conn = ds.getConnection("borg", "");
 
You must specify the following attributes in your JNDI directory:
databaseName
The name of the mSQL database.
encoding
The character set encoding for this connection. If you don't know what that means, set it to "8859_1" and everything will work fine.
loginTimeout
This is not used yet, so set it to 0.
password
You can configure a data source with a password to use for connections, thereby not requiring individual applications to know a user name/password. Right now, this does not matter for mSQL since mSQL does not require passwords. But it might in the future.
port
The server port to which mSQL is listening. If you do not know this value, try 1114.
serverName
The name of the server on which mSQL is running.
user
The user name to use for the database connection.

Last modified $Date: 1999/07/09 23:16:26 $

Version:
$Revision: 1.1.2.1 $
Author:
George Reese (borg@imaginary.com)

Constructor Index

 o MsqlDataSource()
Constructs a new MsqlDataSource without any values.

Method Index

 o getConnection()
Creates an mSQL connection using the configured user name and password for the JNDI directory entry.
 o getConnection(Properties)
Creates a connection using the specified properties.
 o getConnection(String, String)
Provides a database connection using a user and password not configured in the JNDI directory.
 o getDatabaseName()
 o getEncoding()
 o getLoginTimeout()
This feature is not implemented.
 o getLogWriter()
 o getPort()
 o getReference()
Required method to support this class as a Referenceable.
 o getServerName()
 o getURL()
The JDBC URL that would be used to create the same sort of connection used by this data source.
 o getUser()
 o setDatabaseName(String)
Sets the database name.
 o setEncoding(String)
Sets the encoding to use for this connection.
 o setLoginTimeout(int)
This feature is not yet implemented.
 o setLogWriter(PrintWriter)
Sets the log writer for this data source.
 o setPassword(String)
Sets the password to use for connecting to the database
 o setPort(int)
Sets the database port.
 o setServerName(String)
Sets the server name.
 o setUser(String)
Sets the user ID.

Constructors

 o MsqlDataSource
 public MsqlDataSource()
Constructs a new MsqlDataSource without any values. It is also used by serialization.

Methods

 o getConnection
 public Connection getConnection() throws SQLException
Creates an mSQL connection using the configured user name and password for the JNDI directory entry.

Returns:
a database connection
 o getConnection
 public Connection getConnection(String uid,
                                 String pw) throws SQLException
Provides a database connection using a user and password not configured in the JNDI directory.

Parameters:
uid - the user ID to connect with
pw - the password to use for the connection
Returns:
a database connection
 o getConnection
 protected Connection getConnection(Properties props) throws SQLException
Creates a connection using the specified properties.

Parameters:
props - the properties to use for the connection
Returns:
a database connection
 o getDatabaseName
 public String getDatabaseName()
Returns:
the name of the mSQL database to connect to
 o getEncoding
 public String getEncoding()
Returns:
the character set encoding
 o getLogWriter
 public PrintWriter getLogWriter() throws SQLException
Returns:
the error log.
 o getLoginTimeout
 public int getLoginTimeout() throws SQLException
This feature is not implemented.

Returns:
0
 o getPort
 public int getPort()
Returns:
the mSQL port on which the database is listening.
 o getReference
 public Reference getReference() throws NamingException
Required method to support this class as a Referenceable.

Returns:
a reference to this object
 o getServerName
 public String getServerName()
Returns:
the name of the server on which mSQL resides
 o getURL
 public String getURL()
The JDBC URL that would be used to create the same sort of connection used by this data source.

Returns:
the JDBC URL for this data source
 o getUser
 public String getUser()
Returns:
user ID for the connection
 o setDatabaseName
 public void setDatabaseName(String nom)
Sets the database name.

Parameters:
nom - the name of the database
 o setEncoding
 public void setEncoding(String enc)
Sets the encoding to use for this connection.

Parameters:
enc - the encoding
 o setLogWriter
 public void setLogWriter(PrintWriter out) throws SQLException
Sets the log writer for this data source.

Parameters:
out - the new log writer
 o setLoginTimeout
 public void setLoginTimeout(int seconds) throws SQLException
This feature is not yet implemented.

Parameters:
seconds - ignore this
Returns:
java.sql.SQLException this is never thrown
 o setPassword
 public void setPassword(String pass)
Sets the password to use for connecting to the database

Parameters:
pass - the password
 o setPort
 public void setPort(int p)
Sets the database port.

Parameters:
p - the port
 o setServerName
 public void setServerName(String nom)
Sets the server name.

Parameters:
nom - the server name
 o setUser
 public void setUser(String uid)
Sets the user ID.

Parameters:
uid - the user ID

All Packages  Class Hierarchy  This Package  Previous  Next  Index