/** * INTERNAL: * Connect directly - without using DriverManager. Return the Connection. * @return java.sql.Connection */ protected Connection directConnect(Properties properties) throws DatabaseException { if(this.driver == null) { this.instantiateDriver(); } try { return this.driver.connect(this.getConnectionString(), properties); } catch (SQLException exception) { this.clearDriverClassAndDriver(); throw DatabaseException.sqlException(exception, true); } }
/** * PUBLIC: * Return the JDBC connection string. * This is a combination of the driver-specific URL header and the database URL. */ public String getConnectionString() { if(this.getDriverURLHeader() == null) { return this.getDatabaseURL(); } else if(this.getDatabaseURL() == null) { return this.getDriverURLHeader(); } return this.getDriverURLHeader() + this.getDatabaseURL(); }
/** * PUBLIC: * Construct a Connector with the specified settings. */ public DefaultConnector(String driverClassName, String driverURLHeader, String databaseURL) { this.initialize(driverClassName, driverURLHeader, databaseURL); }
this.loadDriverClass(session); String connectionString = this.getConnectionString(); if (this.shouldUseDriverManager(properties, session)) { try { return DriverManager.getConnection(this.getConnectionString(), properties); } catch (SQLException sqlException) { driverManagerException = sqlException; try { Connection directConnection = this.directConnect(properties); if (null == directConnection) { getDriverClassName(), properties.getProperty("user"), getDatabaseURL()); } else { throw DatabaseException.unableToAcquireConnectionFromDriverException( getDriverClassName(), driverClass.getCanonicalName(), getDatabaseURL());
} else { if (oldDefaultConnector != null) { isNewDriverRequired = isPropertyValueToBeUpdated(oldDefaultConnector.getDriverClassName(), driver); isNewConnectionStringRequired = isPropertyValueToBeUpdated(oldDefaultConnector.getConnectionString(), connectionString); newLogin.setConnector(new DefaultConnector()); newLogin.setUsesExternalConnectionPooling(false); } else if (isNewJNDIConnectorRequired) { if (isNewDriverRequired != null) { if (isNewDriverRequired) { defaultConnector.setDriverClassName(driver); } else { defaultConnector.setDriverClassName(null); defaultConnector.setDatabaseURL(connectionString); } else { defaultConnector.setDatabaseURL(null);
/** * PUBLIC: * Provide the details of my connection information. This is primarily for JMX runtime services. * @return java.lang.String */ public String getConnectionDetails() { return this.getConnectionString(); }
if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){ try { driverClass = AccessController.doPrivileged(new PrivilegedClassForName(this.getDriverClassName(), true, session.getPlatform().getConversionManager().getLoader())); } catch (PrivilegedActionException exception) { throw DatabaseException.configurationErrorClassNotFound(this.getDriverClassName()); driverClass = PrivilegedAccessHelper.getClassForName(this.getDriverClassName(), true, session.getPlatform().getConversionManager().getLoader()); driverClass = AccessController.doPrivileged(new PrivilegedClassForName(this.getDriverClassName(), true, ConversionManager.getDefaultManager().getLoader())); } catch (PrivilegedActionException exception) { throw DatabaseException.configurationErrorClassNotFound(this.getDriverClassName()); } } else { driverClass = PrivilegedAccessHelper.getClassForName(this.getDriverClassName(), true, ConversionManager.getDefaultManager().getLoader()); clearDriverClassAndDriver(); throw DatabaseException.configurationErrorClassNotFound(this.getDriverClassName());
/** * PUBLIC: * Connect to the JDBC driver via DriverManager. * @see #useDirectDriverConnect(String, String, String) */ public void useDefaultDriverConnect(String driverClassName, String driverURLHeader, String databaseURL) { setConnector(new DefaultConnector(driverClassName, driverURLHeader, databaseURL)); }
/** * PUBLIC: * The driver class is the name of the Java class for the JDBC driver being used * (e.g. "sun.jdbc.odbc.JdbcOdbcDriver"). */ public void setDriverClassName(String driverClassName) { this.driverClassName = driverClassName; // if driver class name changed then discard the cached driver class and driver. clearDriverClassAndDriver(); }
/** * PUBLIC: * The driver class is the name of the Java class for the JDBC driver being used * (e.g. "sun.jdbc.odbc.JdbcOdbcDriver"). */ public String getDriverClassName() { if (!(getConnector() instanceof DefaultConnector)) { return ""; } return getDefaultConnector().getDriverClassName(); }
/** * PUBLIC: * The database URL is the JDBC URL for the database server. * The driver header is <i>not</i> be included in this URL * (e.g. "dbase files"; not "jdbc:odbc:dbase files"). */ public String getDatabaseURL() { if (!(getConnector() instanceof DefaultConnector)) { return ""; } return getDefaultConnector().getDatabaseURL(); }
/** * 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. */ public String getDriverURLHeader() { if (!(getConnector() instanceof DefaultConnector)) { return ""; } return getDefaultConnector().getDriverURLHeader(); }
this.loadDriverClass(session); String connectionString = this.getConnectionString(); if (this.shouldUseDriverManager(properties, session)) { try { return DriverManager.getConnection(this.getConnectionString(), properties); } catch (SQLException sqlException) { driverManagerException = sqlException; try { Connection directConnection = this.directConnect(properties); if (null == directConnection) { getDriverClassName(), properties.getProperty("user"), getDatabaseURL()); } else { throw DatabaseException.unableToAcquireConnectionFromDriverException( getDriverClassName(), driverClass.getCanonicalName(), getDatabaseURL());
/** * PUBLIC: * Provide the details of my connection information. This is primarily for JMX runtime services. * @return java.lang.String */ public String getConnectionDetails() { return this.getConnectionString(); }
if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){ try { driverClass = AccessController.doPrivileged(new PrivilegedClassForName(this.getDriverClassName(), true, session.getPlatform().getConversionManager().getLoader())); } catch (PrivilegedActionException exception) { throw DatabaseException.configurationErrorClassNotFound(this.getDriverClassName()); driverClass = PrivilegedAccessHelper.getClassForName(this.getDriverClassName(), true, session.getPlatform().getConversionManager().getLoader()); driverClass = AccessController.doPrivileged(new PrivilegedClassForName(this.getDriverClassName(), true, ConversionManager.getDefaultManager().getLoader())); } catch (PrivilegedActionException exception) { throw DatabaseException.configurationErrorClassNotFound(this.getDriverClassName()); } } else { driverClass = PrivilegedAccessHelper.getClassForName(this.getDriverClassName(), true, ConversionManager.getDefaultManager().getLoader()); clearDriverClassAndDriver(); throw DatabaseException.configurationErrorClassNotFound(this.getDriverClassName());
/** * PUBLIC: * Connect to the JDBC driver via DriverManager. * @see #useDirectDriverConnect() */ public void useDefaultDriverConnect() { setConnector(new DefaultConnector()); }
/** * PUBLIC: * The driver class is the name of the Java class for the JDBC driver being used * (e.g. "sun.jdbc.odbc.JdbcOdbcDriver"). */ public void setDriverClassName(String driverClassName) { this.driverClassName = driverClassName; // if driver class name changed then discard the cached driver class and driver. clearDriverClassAndDriver(); }
/** * PUBLIC: * The driver class is the name of the Java class for the JDBC driver being used * (e.g. "sun.jdbc.odbc.JdbcOdbcDriver"). */ public String getDriverClassName() { if (!(getConnector() instanceof DefaultConnector)) { return ""; } return getDefaultConnector().getDriverClassName(); }
/** * PUBLIC: * The database URL is the JDBC URL for the database server. * The driver header is <i>not</i> be included in this URL * (e.g. "dbase files"; not "jdbc:odbc:dbase files"). */ public String getDatabaseURL() { if (!(getConnector() instanceof DefaultConnector)) { return ""; } return getDefaultConnector().getDatabaseURL(); }
/** * 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. */ public String getDriverURLHeader() { if (!(getConnector() instanceof DefaultConnector)) { return ""; } return getDefaultConnector().getDriverURLHeader(); }