/** * Attempt to establish a database connection in a non-pooling, non-distributed environment. * * @return a Connection to the database * @throws java.sql.SQLException if a database-access error occurs. */ public Connection getConnection() throws SQLException { LogWriter dncLogWriter = null; try { updateDataSourceValues(tokenizeAttributes(getConnectionAttributes(), null)); dncLogWriter = super.computeDncLogWriterForNewConnection("_sds"); return getConnectionX(dncLogWriter, getUser(), getPassword()); } catch (SqlException se) { // The method below may throw an exception. handleConnectionException(dncLogWriter, se); // If the exception wasn't handled so far, re-throw it. throw se.getSQLException(); } }
/** * Attempt to establish a database connection in a non-pooling, non-distributed environment. * * @param user the database user on whose behalf the Connection is being made * @param password the user's password * @return a Connection to the database * @throws java.sql.SQLException if a database-access error occurs. */ public Connection getConnection(String user, String password) throws SQLException { // Jdbc 2 connections will write driver trace info on a // datasource-wide basis using the jdbc 2 data source log writer. // This log writer may be narrowed to the connection-level // This log writer will be passed to the agent constructor. LogWriter dncLogWriter = null; try { updateDataSourceValues(tokenizeAttributes(getConnectionAttributes(), null)); dncLogWriter = super.computeDncLogWriterForNewConnection("_sds"); return getConnectionX(dncLogWriter, user, password); } catch (SqlException se) { // The method below may throw an exception. handleConnectionException(dncLogWriter, se); // If the exception wasn't handled so far, re-throw it. throw se.getSQLException(); } }