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)
-
MsqlDataSource()
- Constructs a new
MsqlDataSource
without any values.
-
getConnection()
- Creates an mSQL connection using the configured user name and
password for the JNDI directory entry.
-
getConnection(Properties)
- Creates a connection using the specified properties.
-
getConnection(String, String)
- Provides a database connection using a user and password not
configured in the JNDI directory.
-
getDatabaseName()
-
-
getEncoding()
-
-
getLoginTimeout()
- This feature is not implemented.
-
getLogWriter()
-
-
getPort()
-
-
getReference()
- Required method to support this class as a
Referenceable
.
-
getServerName()
-
-
getURL()
- The JDBC URL that would be used to create the same sort of
connection used by this data source.
-
getUser()
-
-
setDatabaseName(String)
- Sets the database name.
-
setEncoding(String)
- Sets the encoding to use for this connection.
-
setLoginTimeout(int)
- This feature is not yet implemented.
-
setLogWriter(PrintWriter)
- Sets the log writer for this data source.
-
setPassword(String)
- Sets the password to use for connecting to the database
-
setPort(int)
- Sets the database port.
-
setServerName(String)
- Sets the server name.
-
setUser(String)
- Sets the user ID.
MsqlDataSource
public MsqlDataSource()
- Constructs a new
MsqlDataSource
without any values. It
is also used by serialization.
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
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
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
getDatabaseName
public String getDatabaseName()
- Returns:
- the name of the mSQL database to connect to
getEncoding
public String getEncoding()
- Returns:
- the character set encoding
getLogWriter
public PrintWriter getLogWriter() throws SQLException
- Returns:
- the error log.
getLoginTimeout
public int getLoginTimeout() throws SQLException
- This feature is not implemented.
- Returns:
- 0
getPort
public int getPort()
- Returns:
- the mSQL port on which the database is listening.
getReference
public Reference getReference() throws NamingException
- Required method to support this class as a
Referenceable
.
- Returns:
- a reference to this object
getServerName
public String getServerName()
- Returns:
- the name of the server on which mSQL resides
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
getUser
public String getUser()
- Returns:
- user ID for the connection
setDatabaseName
public void setDatabaseName(String nom)
- Sets the database name.
- Parameters:
- nom - the name of the database
setEncoding
public void setEncoding(String enc)
- Sets the encoding to use for this connection.
- Parameters:
- enc - the encoding
setLogWriter
public void setLogWriter(PrintWriter out) throws SQLException
- Sets the log writer for this data source.
- Parameters:
- out - the new log writer
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
setPassword
public void setPassword(String pass)
- Sets the password to use for connecting to the database
- Parameters:
- pass - the password
setPort
public void setPort(int p)
- Sets the database port.
- Parameters:
- p - the port
setServerName
public void setServerName(String nom)
- Sets the server name.
- Parameters:
- nom - the server name
setUser
public void setUser(String uid)
- Sets the user ID.
- Parameters:
- uid - the user ID
All Packages Class Hierarchy This Package Previous Next Index