use of org.firebirdsql.jca.FBConnectionRequestInfo in project jaybird by FirebirdSQL.
the class FBDataSource method getConnection.
/**
* <p>Attempt to establish a database connection.
*
* @param username
* the database user on whose behalf the Connection is
* being made
* @param password
* the user's password
* @return a Connection to the database
* @throws SQLException
* if a database-access error occurs.
*/
@SuppressWarnings("deprecation")
public Connection getConnection(String username, String password) throws SQLException {
try {
// mcf makes a copy for us.
FBConnectionRequestInfo subjectCri = mcf.getDefaultConnectionRequestInfo();
subjectCri.setUserName(username);
subjectCri.setPassword(password);
return (Connection) cm.allocateConnection(mcf, subjectCri);
} catch (ResourceException re) {
if (re.getCause() instanceof SQLException) {
throw (SQLException) re.getCause();
}
if (re.getLinkedException() instanceof SQLException) {
throw (SQLException) re.getLinkedException();
}
throw new FBSQLException(re);
}
}
Aggregations