Mimer JDBC Engine 2.12

com.mimer.jdbc
Class MimerDataSource

java.lang.Object
  |
  +--com.mimer.jdbc.MimerDataSource
All Implemented Interfaces:
DataSource, Referenceable, Serializable
Direct Known Subclasses:
MimerConnectionPoolDataSource, MimerXADataSource

public class MimerDataSource
extends Object
implements DataSource, Referenceable, Serializable

MimerDataSource implements the javax.sql.DataSource interface and may serve several purposes.

In an enterprise environment, objects of this class may be configured and stored in a JNDI pool for later retrieval. This feature is only supported by the Mimer JDBC Engine driver (mimjdbc). For examples on how to configure and store MimerDataSource objects in a JNDI pool, see the Mimer JDBC Guide.

The J2ME-drivers (minjdbc and midjdbc) supplies a MimerDataSource class as the preferred method of making a connection. These drivers does not support being stored in a JNDI pool.

The MimerDataSource class supports Javabeans. This means this class may be configured using generic IDE tools.

Before a connection is attempted by calling MimerDataSource.getConnection the database name attribute must be set. This specifies database on the host to connect to. Use setDatabaseName(java.lang.String) to set this attribute.

See Also:
Serialized Form

Constructor Summary
MimerDataSource()
           
 
Method Summary
 Connection getConnection()
          Attempts the connection to the host with the specified database, user and password.
 Connection getConnection(String user, String password)
          Attempts the connection to the host with the specified user and password.
 String getDatabaseName()
          Returns the database name associated with the DataSource object.
 String getDescription()
          Returns the description of the database.
 int getLoginTimeout()
          Returns the current login timeout of the DataSource object. 0 implies no timeout.
 PrintWriter getLogWriter()
           
 String getPassword()
          Returns the password associated with thie DataSource object.
 int getPortNumber()
          Gets the port number associated with the DataSource object.
 Reference getReference()
           
 String getServerName()
          Returns the host name of the DataSource object.
 String getUser()
          Returns the user name associated with the DataSource object.
 void setDatabaseName(String databaseName)
          Sets the database name to connect to.
 void setDescription(String description)
          A plausible description of the database.
 void setLoginTimeout(int timeout)
          Sets the login timeout in seconds.
 void setLogWriter(PrintWriter out)
           
 void setPassword(String passWord)
          Sets the password of the database user to connect as.
 void setPortNumber(int portNumber)
          Sets the IP port number to use when connecting to the Mimer SQL Server.
 void setServerName(String serverName)
          The host machine of the server to connect to.
 void setUser(String userName)
          The database user to connect as.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MimerDataSource

public MimerDataSource()
Method Detail

getConnection

public Connection getConnection()
                         throws SQLException
Attempts the connection to the host with the specified database, user and password.

Before calling this method, the following attributes should be set.

  • Database name.
  • User name. The user in the database to connect as. Use setUser(java.lang.String) to set this attribute.
  • Password. The password of the above user. Use setPassword(java.lang.String) to set this attribute.
  • Specified by:
    getConnection in interface DataSource
    Returns:
    The new connection.
    Throws:
    SQLException - if an error occurs. SQLSTATE 08004 is thrown if the connection failed because of a wrong user or password, or if an attempt was made to connect to a Mimer SQL server older than 8.2. 08001 is thrown if the connection failed because the server could not be contacted, perhaps it was down.

    getConnection

    public Connection getConnection(String user,
                                    String password)
                             throws SQLException
    Attempts the connection to the host with the specified user and password.

    Before calling this method, the following attributes should be set.

  • Database name.

    Specified by:
    getConnection in interface DataSource
    Returns:
    The new connection.
    Throws:
    SQLException - if an error occurs. SQLSTATE 08004 is thrown if the connection failed because of a wrong user or password, or if an attempt was made to connect to a Mimer SQL server older than 8.2. 08001 is thrown if the connection failed because the server could not be contacted, perhaps it was down.

  • getDatabaseName

    public String getDatabaseName()
    Returns the database name associated with the DataSource object.

    See Also:
    setDatabaseName(java.lang.String)

    getDescription

    public String getDescription()
    Returns the description of the database.

    See Also:
    setDescription(java.lang.String)

    getLoginTimeout

    public int getLoginTimeout()
    Returns the current login timeout of the DataSource object. 0 implies no timeout.

    Specified by:
    getLoginTimeout in interface DataSource
    See Also:
    setLoginTimeout(int)

    getLogWriter

    public PrintWriter getLogWriter()
    Specified by:
    getLogWriter in interface DataSource

    getPassword

    public String getPassword()
    Returns the password associated with thie DataSource object.

    See Also:
    getPassword()

    getPortNumber

    public int getPortNumber()
    Gets the port number associated with the DataSource object.

    See Also:
    setPortNumber(int)

    getReference

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

    getServerName

    public String getServerName()
    Returns the host name of the DataSource object.

    See Also:
    setServerName(java.lang.String)

    getUser

    public String getUser()
    Returns the user name associated with the DataSource object.

    See Also:
    setUser(java.lang.String)

    setDatabaseName

    public void setDatabaseName(String databaseName)
    Sets the database name to connect to. This name must be setup on the host before connecting. On Microsoft Windows servers, this is done using the Mimer Administrator (MIMADMIN.EXE) in the "local" tab. On OpenVMS servers this name should be found in the MIMER_SQLHOSTS file, and on Unixes in /etc/sqlhosts. See System Administrators Guide for more information on database servers. This attribute must be set before attempting to connect.

    Parameters:
    databaseName - The name of the database to connect to.
    See Also:
    getDatabaseName()

    setDescription

    public void setDescription(String description)
    A plausible description of the database. This text may be used by application servers and other tools to describe to database. The default is "Mimer SQL server".

    Parameters:
    description - A description of the database.
    See Also:
    getDescription()

    setLoginTimeout

    public void setLoginTimeout(int timeout)
                         throws SQLException
    Sets the login timeout in seconds. The default is 0, which implies that there is no timeout.

    Specified by:
    setLoginTimeout in interface DataSource
    Parameters:
    timeout - The requested timeout in seconds. Use 0 to disable connection timeout.
    SQLException
    See Also:
    getLoginTimeout()

    setLogWriter

    public void setLogWriter(PrintWriter out)
    Specified by:
    setLogWriter in interface DataSource

    setPassword

    public void setPassword(String passWord)
    Sets the password of the database user to connect as. See the ALTER IDENT statement in the SQL Reference Manual for information about changing user passwords. This attribute must be set before attempting to connect.

    Parameters:
    passWord - The password.
    See Also:
    getPassword()

    setPortNumber

    public void setPortNumber(int portNumber)
    Sets the IP port number to use when connecting to the Mimer SQL Server.

    Parameters:
    portNumber - The IP port to use. The default is 1360.
    See Also:
    getPortNumber()

    setServerName

    public void setServerName(String serverName)
    The host machine of the server to connect to. This can be either an IP-number such as (192.71.123.253) or a machine name. Default is "localhost".

    Parameters:
    serverName - The host to connect to.
    See Also:
    getServerName()

    setUser

    public void setUser(String userName)
    The database user to connect as. See the CREATE IDENT statement in the SQL Reference Manual for information about creating new database users. This attribute must be set before attempting to connect.

    Parameters:
    userName - The user name, at most 128 characters.
    See Also:
    getUser()

    Mimer JDBC Engine 2.12

    Submit a comment or suggestion Version 2.12 of Mimer JDBC Engine
    Copyright Upright Database Technology AB, Box 1713, SE-751 47 UPPSALA, Sweden. All Rights Reserved.