FileDocCategorySizeDatePackage
DatabaseLogin.javaAPI DocGlassfish v2 API46999Tue May 22 16:54:52 BST 2007oracle.toplink.essentials.sessions

DatabaseLogin

public class DatabaseLogin extends DatasourceLogin

Purpose: Hold the configuration information necessary to connect to a JDBC driver.

Description: A DatabaseLogin is used by a TopLink database session to connect to a JDBC server.

Responsibilities:

  • Hold the driver class name and URL header
  • Hold the database URL
  • Hold any driver-specific database connection properties (e.g. "user", "database")
  • Build the JDBC driver connect string
  • Hold the database platform (e.g. Oracle, DB2)
  • Hold the message logging stream
  • Hold other assorted configuration settings

Fields Summary
public static final int
TRANSACTION_NONE
Transactions are not supported.
public static final int
TRANSACTION_READ_UNCOMMITTED
Dirty reads, non-repeatable reads and phantom reads can occur.
public static final int
TRANSACTION_READ_COMMITTED
Dirty reads are prevented; non-repeatable reads and phantom reads can occur.
public static final int
TRANSACTION_REPEATABLE_READ
Dirty reads and non-repeatable reads are prevented; phantom reads can occur.
public static final int
TRANSACTION_SERIALIZABLE
Dirty reads, non-repeatable reads and phantom reads are prevented.
Constructors Summary
public DatabaseLogin()
PUBLIC: Create a new login.


              
      
        this(new DatabasePlatform());
    
public DatabaseLogin(DatabasePlatform databasePlatform)
ADVANCED: Create a new login for the given platform.

        super(databasePlatform);
        this.useDefaultDriverConnect();
    
Methods Summary
public voidbindAllParameters()
PUBLIC: Bind all arguments to any SQL statement.

        setShouldBindAllParameters(true);
    
public oracle.toplink.essentials.internal.databaseaccess.AccessorbuildAccessor()
INTERNAL: Build and return an appropriate Accessor. The default is a DatabaseAccessor.

        return new DatabaseAccessor();
    
public voidcacheAllStatements()
PUBLIC: Cache all prepared statements, this requires full parameter binding as well.

see
#bindAllParameters()

        setShouldCacheAllStatements(true);
    
public voiddontBindAllParameters()
PUBLIC: Do not bind all arguments to any SQL statement.

        setShouldBindAllParameters(false);
    
public voiddontCacheAllStatements()
PUBLIC: Do not cache all prepared statements.

        setShouldCacheAllStatements(false);
    
public voiddontOptimizeDataConversion()
PUBLIC: Disable driver level data conversion optimization. This can be disabled as some drivers perform data conversion themselves incorrectly.

        setShouldOptimizeDataConversion(false);
    
public voiddontUseByteArrayBinding()
PUBLIC: TopLink can be configured to use parameter binding for large binary data. By default TopLink will print this data as hex through the JDBC binary excape clause. Both binding and printing have various limits on all databases (e.g. 5k - 32k).

        setUsesByteArrayBinding(false);
    
public voiddontUseNativeSQL()
PUBLIC: TopLink can be configured to use database-specific SQL grammar, as opposed to the JDBC standard grammar. This is because, unfortunately, some drivers to not support the full JDBC standard. By default TopLink uses the JDBC SQL grammar.

        setUsesNativeSQL(false);
    
public voiddontUseStreamsForBinding()
PUBLIC: TopLink can be configured to use streams to store large binary data.

        setUsesStreamsForBinding(false);
    
public voiddontUseStringBinding()
PUBLIC: Do not bind strings of any size.

        getPlatform().setStringBindingSize(0);
        getPlatform().setUsesStringBinding(false);
    
protected booleandriverIs(java.lang.String driverName)
INTERNAL: Return whether the specified driver is being used.

        try {
            return getDriverClassName().equals(driverName);
        } catch (ValidationException e) {
            // this exception will be thrown if we are using something other than a DefaultConnector
            return false;
        }
    
public java.lang.StringgetConnectionString()
PUBLIC: Return the JDBC connection string. This is a combination of the driver-specific URL header and the database URL.

        return getDefaultConnector().getConnectionString();
    
public intgetCursorCode()
ADVANCED: Return the code for preparing cursored output parameters in a stored procedure

        return getPlatform().getCursorCode();
    
public java.lang.StringgetDataSourceName()
PUBLIC: The data source name is required if connecting through ODBC (JDBC-ODBC, etc.). This is the ODBC name given in the ODBC Data Source Administrator. This is just the database part of the URL.

        return getDatabaseURL();
    
public java.lang.StringgetDatabaseName()
PUBLIC: The database name is required when connecting to databases that support multiple databases within a single server instance (e.g. Sybase, SQL Server). This is ONLY used when connecting through ODBC type JDBC drivers. This is NEVER used with Oracle.

        return properties.getProperty("database");
    
public java.lang.StringgetDatabaseURL()
PUBLIC: The database URL is the JDBC URL for the database server. The driver header is not be included in this URL (e.g. "dbase files"; not "jdbc:odbc:dbase files").

        return getDefaultConnector().getDatabaseURL();
    
protected oracle.toplink.essentials.sessions.DefaultConnectorgetDefaultConnector()
INTERNAL: Return the connector that will instantiate the java.sql.Connection.

        try {
            return (DefaultConnector)getConnector();
        } catch (ClassCastException e) {
            throw ValidationException.invalidConnector(connector);
        }
    
public java.lang.StringgetDriverClassName()
PUBLIC: The driver class is the name of the Java class for the JDBC driver being used (e.g. "sun.jdbc.odbc.JdbcOdbcDriver").

        return getDefaultConnector().getDriverClassName();
    
public java.lang.StringgetDriverURLHeader()
PUBLIC: The driver URL header is the string predetermined by the JDBC driver to be part of the URL connection string, (e.g. "jdbc:odbc:"). This is required to connect to the database.

        return getDefaultConnector().getDriverURLHeader();
    
public java.lang.StringgetServerName()
PUBLIC: The server name is the name of the database instance. This is ONLY required if using an ODBC JDBC driver and overriding the server name specified in the ODBC Data Source Administrator.

        return properties.getProperty("server");
    
public booleangetShouldBindAllParameters()
PUBLIC: Used to help bean introspection.

        return shouldBindAllParameters();
    
public booleangetShouldCacheAllStatements()
PUBLIC: Used to help bean introspection.

        return shouldCacheAllStatements();
    
public booleangetShouldOptimizeDataConversion()
PUBLIC: Used to help bean introspection.

        return shouldOptimizeDataConversion();
    
public booleangetShouldTrimStrings()
PUBLIC: Used to help bean introspection.

        return shouldTrimStrings();
    
public intgetStatementCacheSize()
PUBLIC: If prepared statement caching is used, return the cache size. The default is 50.

        return getPlatform().getStatementCacheSize();
    
public intgetStringBindingSize()
PUBLIC: Used to help bean introspection.

        return getPlatform().getStringBindingSize();
    
public intgetTransactionIsolation()
PUBLIC: Return the transaction isolation setting for the connection. Return -1 if it has not been set.

        return getPlatform().getTransactionIsolation();
    
public booleangetUsesBinding()
PUBLIC: Used to help bean introspection.

        return shouldUseByteArrayBinding();
    
public booleangetUsesNativeSQL()
PUBLIC: Used to help bean introspection.

        return shouldUseNativeSQL();
    
public booleangetUsesNativeSequencing()
PUBLIC: Used to help bean introspection.

        return shouldUseNativeSequencing();
    
public booleangetUsesStreamsForBinding()
PUBLIC: Used to help bean introspection.

        return shouldUseStreamsForBinding();
    
public booleangetUsesStringBinding()
PUBLIC: Used to help bean introspection.

        return getPlatform().usesStringBinding();
    
public voidhandleTransactionsManuallyForSybaseJConnect()
PUBLIC: Force TopLink to manually begin transactions instead of using autoCommit. Although autoCommit should be used, and work, under JDBC, some drivers (e.g. Sybase JConnect) do not correctly map autoCommit to transactions, so stored procedures may not work correctly. This property should only be used as a workaround for the Sybase JConnect transaction problem.

        getPlatform().setSupportsAutoCommit(false);
    
public booleanisAnyOracleJDBCDriver()
PUBLIC: Return whether an Oracle JDBC driver is being used.

        return oracleDriverIs("jdbc:oracle:");
    
public booleanisCloudscapeJDBCDriver()
PUBLIC: Return whether a Cloudscape JDBC driver is being used.

        return driverIs("COM.cloudscape.core.JDBCDriver");
    
public booleanisDB2JDBCDriver()
PUBLIC: Return whether an IBM DB2 native client JDBC driver is being used.

        return driverIs("COM.ibm.db2.jdbc.app.DB2Driver");
    
public booleanisIntersolvSequeLinkDriver()
PUBLIC: Return whether an Intersolv SeqeLink JDBC driver is being used.

        return driverIs("intersolv.jdbc.sequelink.SequeLinkDriver");
    
public booleanisJConnectDriver()
PUBLIC: Return whether a Sybase JConnect JDBC driver is being used.

        return driverIs("com.sybase.jdbc.SybDriver");
    
public booleanisJDBCConnectDriver()
PUBLIC: Return whether a Borland JDBCConnect JDBC driver is being used.

        return driverIs("borland.jdbc.Bridge.LocalDriver");
    
public booleanisJDBCConnectRemoteDriver()
PUBLIC: Return whether a Borland JDBCConnect JDBC driver is being used.

        return driverIs("borland.jdbc.Broker.RemoteDriver");
    
public booleanisJDBCODBCBridge()
PUBLIC: Return whether a Sun/Merant JDBC-ODBC bridge driver is being used.

        return driverIs("sun.jdbc.odbc.JdbcOdbcDriver");
    
public booleanisOracle7JDBCDriver()
PUBLIC: Return whether an Oracle native 7.x OCI JDBC driver is being used.

        return oracleDriverIs("jdbc:oracle:oci7:@");
    
public booleanisOracleJDBCDriver()
PUBLIC: Return whether an Oracle 8.x native OCI JDBC driver is being used.

        return oracleDriverIs("jdbc:oracle:oci8:@");
    
public booleanisOracleServerJDBCDriver()
PUBLIC: Return whether an Oracle thin JDBC driver is being used.

        return oracleDriverIs("jdbc:oracle:kprb:");
    
public booleanisOracleThinJDBCDriver()
PUBLIC: Return whether an Oracle thin JDBC driver is being used.

        return oracleDriverIs("jdbc:oracle:thin:@");
    
public booleanisWebLogicOracleOCIDriver()
PUBLIC: Return whether a WebLogic Oracle OCI JDBC driver is being used.

        return driverIs("weblogic.jdbc.oci.Driver");
    
public booleanisWebLogicSQLServerDBLibDriver()
PUBLIC: Return whether a WebLogic SQL Server dblib JDBC driver is being used.

        return driverIs("weblogic.jdbc.dblib.Driver");
    
public booleanisWebLogicSQLServerDriver()
PUBLIC: Return whether a WebLogic SQL Server JDBC driver is being used.

        return driverIs("weblogic.jdbc.mssqlserver4.Driver");
    
public booleanisWebLogicSybaseDBLibDriver()
PUBLIC: Return whether a WebLogic Sybase dblib JDBC driver is being used.

        return driverIs("weblogic.jdbc.dblib.Driver");
    
public booleanisWebLogicThinClientDriver()
PUBLIC: Return whether a WebLogic thin client JDBC driver is being used.

        return driverIs("weblogic.jdbc.t3Client.Driver");
    
public booleanisWebLogicThinDriver()
PUBLIC: Return whether a WebLogic thin JDBC driver is being used.

        return driverIs("weblogic.jdbc.t3.Driver");
    
public voidoptimizeDataConversion()
PUBLIC: Enable driver level data conversion optimization. This can be disabled as some drivers perform data conversion themselves incorrectly.

        setShouldOptimizeDataConversion(true);
    
protected booleanoracleDriverIs(java.lang.String urlPrefix)
INTERNAL: Return whether the specified Oracle JDBC driver is being used.

        try {
            if (getDriverURLHeader().length() != 0) {
                return getDriverURLHeader().indexOf(urlPrefix) != -1;
            } else {
                return getDatabaseURL().indexOf(urlPrefix) != -1;
            }
        } catch (ValidationException e) {
            // this exception will be thrown if we are using something other than a DefaultConnector
            return false;
        }
    
public voidsetConnectionString(java.lang.String url)
PUBLIC: Set the JDBC connection string. This is the full JDBC connect URL. Normally TopLink breaks this into two parts to allow for the driver header to be automatically set, however sometimes it is easier just to set the entire URL at once.

        setDriverURLHeader("");
        setDatabaseURL(url);
    
public voidsetCursorCode(int cursorCode)
ADVANCED: Set the code for preparing cursored output parameters in a stored procedure

        getPlatform().setCursorCode(cursorCode);
    
public voidsetDatabaseName(java.lang.String databaseName)
PUBLIC: The database name is required when connecting to databases that support multiple databases within a single server instance (e.g. Sybase, SQL Server). This is ONLY used when connecting through ODBC type JDBC drivers. This is NEVER used with Oracle.

        setProperty("database", databaseName);
    
public voidsetDatabaseURL(java.lang.String databaseURL)
PUBLIC: The database URL is the JDBC URL for the database server. The driver header should not be included in this URL (e.g. "dbase files"; not "jdbc:odbc:dbase files").

        getDefaultConnector().setDatabaseURL(databaseURL);
    
public voidsetDefaultNullValue(java.lang.Class type, java.lang.Object value)
PUBLIC: The default value to substitute for database NULLs can be configured on a per-class basis. Example: login.setDefaultNullValue(long.class, new Long(0))

        getPlatform().getConversionManager().setDefaultNullValue(type, value);
    
public voidsetDriverClass(java.lang.Class driverClass)
PUBLIC: The driver class is the Java class for the JDBC driver to be used (e.g. sun.jdbc.odbc.JdbcOdbcDriver.class).

        setDriverClassName(driverClass.getName());
    
public voidsetDriverClassName(java.lang.String driverClassName)
PUBLIC: The name of the JDBC driver class to be used (e.g. "sun.jdbc.odbc.JdbcOdbcDriver").

        getDefaultConnector().setDriverClassName(driverClassName);
    
public voidsetDriverURLHeader(java.lang.String driverURLHeader)
PUBLIC: The driver URL header is the string predetermined by the JDBC driver to be part of the URL connection string, (e.g. "jdbc:odbc:"). This is required to connect to the database.

        getDefaultConnector().setDriverURLHeader(driverURLHeader);
    
public voidsetODBCDataSourceName(java.lang.String dataSourceName)
PUBLIC: The data source name is required if connecting through ODBC (JDBC-ODBC, etc.). This is the ODBC name given in the ODBC Data Source Administrator. This is just the database part of the URL.

        setDatabaseURL(dataSourceName);
    
public voidsetServerName(java.lang.String name)
PUBLIC: The server name is the name of the database instance. This is ONLY used when connecting through ODBC type JDBC drivers, and only if the data source does not specify it already.

        setProperty("server", name);
    
public voidsetShouldBindAllParameters(boolean shouldBindAllParameters)
PUBLIC: Set whether to bind all arguments to any SQL statement.

        getPlatform().setShouldBindAllParameters(shouldBindAllParameters);
    
public voidsetShouldCacheAllStatements(boolean shouldCacheAllStatements)
PUBLIC: Set whether prepared statements should be cached.

        getPlatform().setShouldCacheAllStatements(shouldCacheAllStatements);
    
public voidsetShouldForceFieldNamesToUpperCase(boolean shouldForceFieldNamesToUpperCase)
ADVANCED: This setting can be used if the application expects upper case but the database does not return consistent case (e.g. different databases).

        getPlatform().setShouldForceFieldNamesToUpperCase(shouldForceFieldNamesToUpperCase);
    
public static voidsetShouldIgnoreCaseOnFieldComparisons(boolean shouldIgnoreCaseOnFieldComparisons)
ADVANCED: Allow for case in field names to be ignored as some databases are not case sensitive. When using custom this can be an issue if the fields in the descriptor have a different case.

        DatabasePlatform.setShouldIgnoreCaseOnFieldComparisons(shouldIgnoreCaseOnFieldComparisons);
    
public voidsetShouldOptimizeDataConversion(boolean value)
PUBLIC: Set whether driver level data conversion optimization is enabled. This can be disabled as some drivers perform data conversion themselves incorrectly.

        getPlatform().setShouldOptimizeDataConversion(value);
    
public voidsetShouldTrimStrings(boolean shouldTrimStrings)
PUBLIC: By default CHAR field values have trailing blanks trimmed, this can be configured.

        getPlatform().setShouldTrimStrings(shouldTrimStrings);
    
public voidsetStatementCacheSize(int size)
PUBLIC: If prepared statement caching is used this configures the cache size. The default is 50.

        getPlatform().setStatementCacheSize(size);
    
public voidsetStringBindingSize(int stringBindingSize)
PUBLIC: Used to help bean introspection.

        getPlatform().setStringBindingSize(stringBindingSize);
    
public voidsetTableQualifier(java.lang.String qualifier)
PUBLIC: Set the default qualifier for all tables. This can be the creator of the table or database name the table exists on. This is required by some databases such as Oracle and DB2.

        getPlatform().setTableQualifier(qualifier);
    
public voidsetTransactionIsolation(int isolationLevel)
PUBLIC: Set the transaction isolation setting for the connection. This is an optional setting. The default isolation level set on the database will apply if it is not set here. Use one of the TRANSACTION_* constants for valid input values. Note: This setting will only take effect upon connection.

        getPlatform().setTransactionIsolation(isolationLevel);
    
public voidsetUsesByteArrayBinding(boolean value)
PUBLIC: TopLink can be configured to use parameter binding for large binary data. By default TopLink will print this data as hex through the JDBC binary excape clause. Both binding and printing have various limits on all databases (e.g. 5k - 32k).

        getPlatform().setUsesByteArrayBinding(value);
    
public voidsetUsesNativeSQL(boolean value)
PUBLIC: TopLink can be configured to use database specific sql grammar not JDBC specific. This is because unfortunately some bridges to not support the full JDBC standard. By default TopLink uses the JDBC sql grammar.

        getPlatform().setUsesNativeSQL(value);
    
public voidsetUsesStreamsForBinding(boolean value)
PUBLIC: TopLink can be configured to use streams to store large binary data. This can improve the max size for reading/writing on some JDBC drivers.

        getPlatform().setUsesStreamsForBinding(value);
    
public voidsetUsesStringBinding(boolean usesStringBindingSize)
PUBLIC: Used to help bean introspection.

        getPlatform().setUsesStringBinding(usesStringBindingSize);
    
public booleanshouldBindAllParameters()
PUBLIC: Bind all arguments to any SQL statement.

        return getPlatform().shouldBindAllParameters();
    
public booleanshouldCacheAllStatements()
PUBLIC: Cache all prepared statements, this requires full parameter binding as well.

        return getPlatform().shouldCacheAllStatements();
    
public booleanshouldForceFieldNamesToUpperCase()
ADVANCED: Can be used if the app expects upper case but the database is not return consistent case, i.e. different databases.

        return getPlatform().shouldForceFieldNamesToUpperCase();
    
public static booleanshouldIgnoreCaseOnFieldComparisons()
ADVANCED: Allow for case in field names to be ignored as some databases are not case sensitive. When using custom this can be an issue if the fields in the descriptor have a different case.

        return DatabasePlatform.shouldIgnoreCaseOnFieldComparisons();
    
public booleanshouldOptimizeDataConversion()
PUBLIC: Return if our driver level data conversion optimization is enabled. This can be disabled as some drivers perform data conversion themselves incorrectly.

        return getPlatform().shouldOptimizeDataConversion();
    
public booleanshouldTrimStrings()
PUBLIC: By default CHAR field values have trailing blanks trimmed, this can be configured.

        return getPlatform().shouldTrimStrings();
    
public booleanshouldUseByteArrayBinding()
PUBLIC: TopLink can be configured to use parameter binding for large binary data. By default TopLink will print this data as hex through the JDBC binary excape clause. Both binding and printing have various limits on all databases (e.g. 5k - 32k).

        return getPlatform().usesByteArrayBinding();
    
public booleanshouldUseNativeSQL()
PUBLIC: TopLink can be configured to use database-specific SQL grammar, as opposed to the JDBC standard grammar. This is because, unfortunately, some drivers to not support the full JDBC standard. By default TopLink uses the JDBC SQL grammar.

        return getPlatform().usesNativeSQL();
    
public booleanshouldUseNativeSequencing()
PUBLIC: TopLink can be configured to use a sequence table or native sequencing to generate unique object IDs. Native sequencing uses the ID generation service provided by the database (e.g. SEQUENCE objects on Oracle and IDENTITY columns on Sybase). By default a sequence table is used. Using a sequence table is recommended as it supports preallocation. (Native sequencing on Sybase/SQL Server/Informix does not support preallocation. Preallocation can be supported on Oracle by setting the increment size of the SEQUENCE object to match the preallocation size.)

        return getPlatform().getDefaultSequence() instanceof NativeSequence;
    
public booleanshouldUseStreamsForBinding()
PUBLIC: TopLink can be configured to use streams to store large binary data.

        return getPlatform().usesStreamsForBinding();
    
public booleanshouldUseStringBinding()
PUBLIC: TopLink can be configured to bind large strings.

        return getPlatform().usesStringBinding();
    
public java.lang.StringtoString()
PUBLIC: Print all of the connection information.

        StringWriter stringWriter = new StringWriter();
        PrintWriter writer = new PrintWriter(stringWriter);
        writer.println("DatabaseLogin(");
        writer.println("\t" + ToStringLocalization.buildMessage("platform", (Object[])null) + "=>" + getPlatform());
        writer.println("\t" + ToStringLocalization.buildMessage("user_name", (Object[])null) + "=> \"" + getUserName() + "\"");
        writer.print("\t");
        getConnector().toString(writer);
        if (getServerName() != null) {
            writer.println("\t" + ToStringLocalization.buildMessage("server_name", (Object[])null) + "=> \"" + getServerName() + "\"");
        }
        if (getDatabaseName() != null) {
            writer.println("\t" + ToStringLocalization.buildMessage("database_name", (Object[])null) + "=> \"" + getDatabaseName() + "\"");
        }
        writer.write(")");
        return stringWriter.toString();
    
public voiduseAccess()
PUBLIC: Set the database platform to be Access.

        if (getPlatform().isAccess()) {
            return;
        }

        DatabasePlatform newPlatform = new AccessPlatform();
        getPlatform().copyInto(newPlatform);
        setPlatform(newPlatform);
    
public voiduseByteArrayBinding()
PUBLIC: TopLink can be configured to use parameter binding for large binary data. By default TopLink will print this data as hex through the JDBC binary excape clause. Both binding and printing have various limits on all databases (e.g. 5k - 32k).

        setUsesByteArrayBinding(true);
    
public voiduseCloudscape()
PUBLIC: Set the database platform to be Cloudscape.

        if (getPlatform().isCloudscape()) {
            return;
        }

        DatabasePlatform newPlatform = new CloudscapePlatform();
        getPlatform().copyInto(newPlatform);
        setPlatform(newPlatform);
    
public voiduseCloudscapeDriver()
PUBLIC: Use the Cloudscape JDBC driver.

        useCloudscape();
        setDriverClassName("COM.cloudscape.core.JDBCDriver");
        setDriverURLHeader("jdbc:cloudscape:");
    
public voiduseDB2()
PUBLIC: Set the database platform to be DB2.

        if (getPlatform().isDB2()) {
            return;
        }

        DatabasePlatform newPlatform = new DB2Platform();
        getPlatform().copyInto(newPlatform);
        setPlatform(newPlatform);
    
public voiduseDB2JDBCDriver()
PUBLIC: Use the IBM DB2 native client interface.

        useDB2();
        setDriverClassName("COM.ibm.db2.jdbc.app.DB2Driver");
        setDriverURLHeader("jdbc:db2:");
        useStreamsForBinding();// Works best with IBM driver
    
public voiduseDB2NetJDBCDriver()
PUBLIC: Use the IBM DB2 thin JDBC driver.

        useDB2();
        setDriverClassName("COM.ibm.db2.jdbc.net.DB2Driver");
        setDriverURLHeader("jdbc:db2:");
        useStreamsForBinding();// Works best with IBM driver
    
public voiduseDBase()
PUBLIC: Set the database platform to be DBase.

        if (getPlatform().isDBase()) {
            return;
        }

        DatabasePlatform newPlatform = new DBasePlatform();
        getPlatform().copyInto(newPlatform);
        setPlatform(newPlatform);
    
public voiduseDataSource(java.lang.String dataSource)
PUBLIC: Specify the J2EE DataSource name to connect to. Also enable external connection pooling.

see
JNDIConnector

        setConnector(new JNDIConnector(dataSource));
        useExternalConnectionPooling();
    
public voiduseDefaultDriverConnect()
PUBLIC: Connect to the JDBC driver via DriverManager.

see
#useDirectDriverConnect()

        setConnector(new DefaultConnector());
    
public voiduseDefaultDriverConnect(java.lang.String driverClassName, java.lang.String driverURLHeader, java.lang.String databaseURL)
PUBLIC: Connect to the JDBC driver via DriverManager.

see
#useDirectDriverConnect(String, String, String)

        setConnector(new DefaultConnector(driverClassName, driverURLHeader, databaseURL));
    
public voiduseDerby()

        if (getPlatform().isDerby()) {
            return;
        }

        DatabasePlatform newPlatform = new DerbyPlatform();
        getPlatform().copyInto(newPlatform);
        setPlatform(newPlatform);
    
public voiduseDirectDriverConnect()
PUBLIC: Some JDBC drivers don't support connecting correctly (via DriverManager), but do support connecting incorrectly (e.g. Castanet).

see
#useDirectDriverConnect()

        setConnector(new DirectConnector());
    
public voiduseDirectDriverConnect(java.lang.String driverClassName, java.lang.String driverURLHeader, java.lang.String databaseURL)
PUBLIC: Some JDBC drivers don't support connecting correctly (via DriverManager), but do support connecting incorrectly (e.g. Castanet).

see
#useDefaultDriverConnect(String, String, String)

        setConnector(new DirectConnector(driverClassName, driverURLHeader, databaseURL));
    
public voiduseExternalConnectionPooling()
PUBLIC: Use external connection pooling, such as WebLogic's JTS driver.

see
#dontUseExternalConnectionPooling()
see
#shouldUseExternalConnectionPooling()

        setUsesExternalConnectionPooling(true);
    
public voiduseExternalTransactionController()
PUBLIC: Use an external transaction controller such as a JTS service

see
#dontUseExternalTransactionController()
see
#shouldUseExternalTransactionController()

        setUsesExternalTransactionController(true);
    
public voiduseHSQL()
PUBLIC: Use the HSQL JDBC driver.

        if (getPlatform().isHSQL()) {
            return;
        }

        DatabasePlatform newPlatform = new HSQLPlatform();
        getPlatform().copyInto(newPlatform);
        setPlatform(newPlatform);
    
public voiduseHSQLDriver()
PUBLIC: Use the HSQL JDBC driver.

        useHSQL();
        setDriverClassName("org.hsqldb.jdbcDriver");
        setDriverURLHeader("jdbc:hsqldb:");
    
public voiduseINetSQLServerDriver()
PUBLIC: Use the i-net SQL Server JDBC driver.

        setDriverClassName("com.inet.tds.TdsDriver");
        setDriverURLHeader("jdbc:inetdae:");
    
public voiduseInformix()
PUBLIC: Set the database platform to be Informix.

        if (getPlatform().isInformix()) {
            return;
        }

        DatabasePlatform newPlatform = new InformixPlatform();
        getPlatform().copyInto(newPlatform);
        setPlatform(newPlatform);
    
public voiduseIntersolvSequeLinkDriver()
PUBLIC: Use the Intersolv/Merant SequeLink JDBC driver.

        setDriverClassName("intersolv.jdbc.sequelink.SequeLinkDriver");
        setDriverURLHeader("jdbc:sequelink:");
    
public voiduseJConnect50Driver()
PUBLIC: Use the Sybase JConnect JDBC driver.

        useSybase();
        setDriverClassName("com.sybase.jdbc2.jdbc.SybDriver");
        setDriverURLHeader("jdbc:sybase:Tds:");
        // JConnect does not support the JDBC SQL grammar
        useNativeSQL();
    
public voiduseJConnectDriver()
PUBLIC: Use the Sybase JConnect JDBC driver.

        useSybase();
        setDriverClassName("com.sybase.jdbc.SybDriver");
        setDriverURLHeader("jdbc:sybase:Tds:");
        // JConnect does not support the JDBC SQL grammar
        useNativeSQL();
    
public voiduseJDBC()
PUBLIC: Set the database platform to be JDBC.

        DatabasePlatform newPlatform = new DatabasePlatform();
        getPlatform().copyInto(newPlatform);
        setPlatform(newPlatform);
    
public voiduseJDBCConnectDriver()
PUBLIC: Use the Borland JDBCConnect JDBC driver.

        setDriverClassName("borland.jdbc.Bridge.LocalDriver");
        setDriverURLHeader("jdbc:BorlandBridge:");
    
public voiduseJDBCConnectRemoteDriver()
PUBLIC: Use the Borland JDBCConnect JDBC driver.

        setDriverClassName("borland.jdbc.Broker.RemoteDriver");
        setDriverURLHeader("jdbc:BorlandBridge:");
    
public voiduseJDBCODBCBridge()
PUBLIC: User the Sun/Merant JDBC-ODBC bridge driver.

        setDriverClassName("sun.jdbc.odbc.JdbcOdbcDriver");
        setDriverURLHeader("jdbc:odbc:");
    
public voiduseJTADataSource(java.lang.String dataSource)
PUBLIC: Specify the J2EE JTA enabled DataSource name to connect to. Also enable external transaction control and connection pooling.

see
JNDIConnector

        useDataSource(dataSource);
        useExternalTransactionController();
    
public voiduseMySQL()
PUBLIC: Set the database platform to be MySQL.

        if (getPlatform().isMySQL()) {
            return;
        }

        DatabasePlatform newPlatform = new MySQL4Platform();
        getPlatform().copyInto(newPlatform);
        setPlatform(newPlatform);
    
public voiduseNativeSQL()
PUBLIC: TopLink can be configured to use database-specific SQL grammar, as opposed to the JDBC standard grammar. This is because, unfortunately, some drivers to not support the full JDBC standard. By default TopLink uses the JDBC SQL grammar.

        setUsesNativeSQL(true);
    
public voiduseNativeSequencing()
PUBLIC: TopLink can be configured to use a sequence table or native sequencing to generate unique object IDs. Native sequencing uses the ID generation service provided by the database (e.g. SEQUENCE objects on Oracle and IDENTITY columns on Sybase). By default a sequence table is used. Using a sequence table is recommended as it supports preallocation. (Native sequencing on Sybase/SQL Server/Informix does not support preallocation. Preallocation can be supported on Oracle by setting the increment size of the SEQUENCE object to match the preallocation size.)

        if(!shouldUseNativeSequencing()) {
            getPlatform().setDefaultSequence(new NativeSequence(getPlatform().getDefaultSequence().getName(), 
                    getPlatform().getDefaultSequence().getPreallocationSize(),
                    getPlatform().getDefaultSequence().getInitialValue()));
        }
    
public voiduseOracle()
PUBLIC: Set the database platform to be Oracle.

        if (getPlatform().isOracle()) {
            return;
        }

        DatabasePlatform newPlatform = new OraclePlatform();
        getPlatform().copyInto(newPlatform);
        setPlatform(newPlatform);
    
public voiduseOracle7JDBCDriver()
PUBLIC: Use the Oracle 7.x native OCI JDBC driver.

        useOracle();
        setDriverClassName("oracle.jdbc.OracleDriver");
        setDriverURLHeader("jdbc:oracle:oci7:@");
        // Oracle works best with stream binding.
        useByteArrayBinding();
        useStreamsForBinding();
    
public voiduseOracleJDBCDriver()
PUBLIC: Use the Oracle 8.x native OCI JDBC driver.

        useOracle();
        setDriverClassName("oracle.jdbc.OracleDriver");
        setDriverURLHeader("jdbc:oracle:oci8:@");
        // Oracle works best with stream binding.
        useByteArrayBinding();
        useStreamsForBinding();
    
public voiduseOracleServerJDBCDriver()
PUBLIC: Use the Oracle server JDBC driver.

        useOracle();
        setDriverClassName("oracle.jdbc.OracleDriver");
        setDriverURLHeader("jdbc:oracle:kprb:");
        // Oracle works best with stream binding.
        useByteArrayBinding();
    
public voiduseOracleThinJDBCDriver()
PUBLIC: Use the Oracle thin JDBC driver.

        useOracle();
        setDriverClassName("oracle.jdbc.OracleDriver");
        setDriverURLHeader("jdbc:oracle:thin:@");
        // Oracle works best with stream binding.
        useByteArrayBinding();
        useStreamsForBinding();
    
public voidusePlatform(oracle.toplink.essentials.internal.databaseaccess.DatabasePlatform platform)
ADVANCED: Set the database platform to be custom platform.

        super.usePlatform((Platform)platform);
    
public voidusePointBase()
PUBLIC: Set the database platform to be PointBase.

        if (getPlatform().isPointBase()) {
            return;
        }

        DatabasePlatform newPlatform = new PointBasePlatform();
        getPlatform().copyInto(newPlatform);
        setPlatform(newPlatform);
    
public voidusePointBaseDriver()
PUBLIC: Use the PointBase JDBC driver.

        usePointBase();
        setDriverClassName("com.pointbase.jdbc.jdbcUniversalDriver");
        setDriverURLHeader("jdbc:pointbase:");
    
public voiduseSQLServer()
PUBLIC: Set the database platform to be SQL Server.

        if (getPlatform().isSQLServer()) {
            return;
        }

        DatabasePlatform newPlatform = new SQLServerPlatform();
        getPlatform().copyInto(newPlatform);
        setPlatform(newPlatform);
    
public voiduseStreamsForBinding()
PUBLIC: TopLink can be configured to use streams to store large binary data.

        setUsesStreamsForBinding(true);
    
public voiduseStringBinding()
PUBLIC: Bind strings larger than 255 characters.

        this.useStringBinding(255);
    
public voiduseStringBinding(int size)
PUBLIC: Bind strings that are larger than the specified size. Strings that are smaller will not be bound.

        getPlatform().setStringBindingSize(size);
        getPlatform().setUsesStringBinding(true);
    
public voiduseSybase()
PUBLIC: Set the database platform to be Sybase.

        if (getPlatform().isSybase()) {
            return;
        }

        DatabasePlatform newPlatform = new SybasePlatform();
        getPlatform().copyInto(newPlatform);
        setPlatform(newPlatform);
    
public voiduseWebLogicDriverCursoredOutputCode()
PUBLIC: Set the prepare cursor code to what the WebLogic Oracle OCI JDBC driver expects.

        setCursorCode(1111);
    
public voiduseWebLogicJDBCConnectionPool(java.lang.String poolName)
PUBLIC: Set a WebLogic JDBC connection pool (a pool must be defined for the entity beans that are to be deployed)

        setDriverClassName("weblogic.jdbc.jts.Driver");
        setConnectionString("jdbc:weblogic:jts:" + poolName);
    
public voiduseWebLogicOracleOCIDriver()
PUBLIC: Use the WebLogic Oracle OCI JDBC driver.

        useOracle();
        setDriverClassName("weblogic.jdbc.oci.Driver");
        setDriverURLHeader("jdbc:weblogic:oracle:");
        // WebLogic has a bug converting dates to strings, which our optimizations require.
        dontOptimizeDataConversion();
        useWebLogicDriverCursoredOutputCode();
    
public voiduseWebLogicSQLServerDBLibDriver()
PUBLIC: Use the WebLogic SQL Server dblib JDBC driver.

        useSQLServer();
        setDriverClassName("weblogic.jdbc.dblib.Driver");
        setDriverURLHeader("jdbc:weblogic:mssqlserver:");
        // WebLogic has a bug converting dates to strings, which our optimizations require.
        dontOptimizeDataConversion();
    
public voiduseWebLogicSQLServerDriver()
PUBLIC: Use the WebLogic SQL Server JDBC driver.

        useSQLServer();
        setDriverClassName("weblogic.jdbc.mssqlserver4.Driver");
        setDriverURLHeader("jdbc:weblogic:mssqlserver4:");
        // WebLogic has a bug converting dates to strings, which our optimizations require.
        dontOptimizeDataConversion();
    
public voiduseWebLogicSybaseDBLibDriver()
PUBLIC: Use the WebLogic Sybase dblib JDBC driver.

        useSybase();
        setDriverClassName("weblogic.jdbc.dblib.Driver");
        setDriverURLHeader("jdbc:weblogic:sybase:");
        // WebLogic has a bug converting dates to strings, which our optimizations require.
        dontOptimizeDataConversion();
    
public voiduseWebLogicThinClientDriver()
PUBLIC: Use the WebLogic thin client JDBC driver.

        setDriverClassName("weblogic.jdbc.t3Client.Driver");
        setDriverURLHeader("jdbc:weblogic:t3Client:");
    
public voiduseWebLogicThinDriver()
PUBLIC: Use the WebLogic thin JDBC driver.

        setDriverClassName("weblogic.jdbc.t3.Driver");
        setDriverURLHeader("jdbc:weblogic:t3:");