In my component class i implemeneted ejbCreate method which connects to the cloudscape database and returns connection. My question is Is it the right thing to do or should it be done in some other way?
it's my first time with ejb.
method ejbRemove() closes the database connection
thank You
it's my first time with ejb.
method ejbRemove() closes the database connection
Code:
public Connection ejbCreate() {
Connection connection = null;
try {
Class.forName("COM.cloudscape.core.RmiJdbcDriver");
connection = DriverManager.getConnection("jdbc:cloudscape:rmi:books");
} catch (ClassNotFoundException classNotFound) {
System.out.println( "Driver Not Found");
System.exit(1);
} catch (SQLException sqlException) {
System.out.println(sqlException.getMessage());
}
return connection;
}
public void ejbRemove(Connection connection) {
try {
connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
thank You
Comment