Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.Connection;
- import javax.naming.Context;
- import javax.naming.InitialContext;
- import javax.sql.DataSource;
- public class ConnectionFactory {
- public static Connection getConnection(String dataSourceName) throws Exception{
- try {
- InitialContext ctx = new InitialContext();
- Context envContext = (Context)ctx.lookup("java:/comp/env");
- DataSource ds = (DataSource)envContext.lookup(“jdbc/ProcBoffice_dbtestDS");
- Connection conn = ds.getConnection();
- conn.setAutoCommit(false);
- return conn;
- } catch (Exception e) {
- throw new Exception("Errore in creazione Connessione : " + e.getMessage());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement