How to establish a connection pool in JDBC?

前端 未结 13 2280
一个人的身影
一个人的身影 2020-11-22 02:43

Can anybody provide examples or links on how to establish a JDBC connection pool?

From searching google I see many different ways of doing this and it is rather conf

13条回答
  •  不知归路
    2020-11-22 02:54

    In the app server we use where I work (Oracle Application Server 10g, as I recall), pooling is handled by the app server. We retrieve a javax.sql.DataSource using a JNDI lookup with a javax.sql.InitialContext.

    it's done something like this

    try {     
       context = new InitialContext();
       jdbcURL = (DataSource) context.lookup("jdbc/CachedDS");
       System.out.println("Obtained Cached Data Source ");
    }
    catch(NamingException e)   
    {  
        System.err.println("Error looking up Data Source from Factory: "+e.getMessage());
    }
    

    (We didn't write this code, it's copied from this documentation.)

提交回复
热议问题