Database Reference
In-Depth Information
} catch (NamingException e) {
e.printStackTrace();
log.severe("NamingException resolviing
datasource, ["+e.getMessage()+"]");
return new
CTUFusionDBAdapterResponse("Sys-1",
e.toString(),null);
}finally{
try {
if(!connection.isClosed()) {
connection.rollback();
connection.close();
}
} catch (SQLException e) {
log.severe("SQLException clossing the
connection, ["+e.getMessage()+"]");
e.printStackTrace();
}
}
return response;
}
3. Speaking of establishing the dynamic connection ( getDynamicConnection ),
the implementation is presented as follows, just to complete the example:
InitialContext context = new InitialContext();
DataSource source = (javax.sql.DataSource)
context.lookup(datasource);
connection = source.getConnection();
connection.setAutoCommit(false);
return connection;
4. Finally, to cover all EJB related details, please see the following CTUFu-
sionDBAdapterResponse class implementation; setters and getters
are omitted here for brevity:
@XmlRootElement(namespace =
"urn:com:telco:ctu:la:adapter:dbadapter:v01")
public class CTUFusionDBAdapterResponse implements
Serializable {
Search WWH ::




Custom Search