facebook

How To configure DB Connection Pool (from built-in tomcat6)?

  1. MyEclipse Archived
  2.  > 
  3. Application Servers and Deployment
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #301313 Reply

    THC
    Member

    I am trying to figure out how to configure DB Connection Pool (from built-in tomcat6). I am needing to use an existing remote oracle DB, and my legacy code I must use creates a connection object based on these kinds of conventions:

    Connection conn = null;
    Context ctx = new InitialContext();
    DataSource ds = (DataSource)ctx.lookup(DB_BACKUP_DATASOURCE_NM);
    conn = ds.getConnection();

    Can I create this pool from the built-in tomcat6, or do I need to instead use a remote/separate tomcat instance? If I can do it from the built-on tomcat, I am not sure how to go about it, and I cannot find any myecliipse documentation on how to proceed. If anyone can help at least point me in the right direction, I would greatly appreciate it. Thanks.

    #301326 Reply

    Loyal Water
    Member

    Can I create this pool from the built-in tomcat6, or do I need to instead use a remote/separate tomcat instance?

    MyEclipse Tomcat is a stripped down version of Tomcat 6 so I would suggest you use another instance. You can setup a connector by pointing it to another instance of Tomcat 6. Let me know if you need any further assistance.

    #301329 Reply

    Brian Fernandes
    Moderator

    THC,

    As nipun suggested, an external instance of Tomcat is preferred simply because it can be a minor pain to locate the files you need to modify to setup the pool.

    To create a datasource, you must do the following in your Tomcat installation (this example sets up a datasource connected to our Embedded Derby database, you will need to replace attribute values depending on the database you intend to use):

    1) Add the following element to the “Context” element in conf/context.xml

    <Resource name=”jdbc/derby” auth=”Container” type=”javax.sql.DataSource”
    username=”classiccars” password=”myeclipse”
    driverClassName=”org.apache.derby.jdbc.ClientDriver”
    url=”jdbc:derby://localhost:1527/myeclipse” maxActive=”8″ maxIdle=”4″/>

    2) Copy the driver JAR into the lib folder

    This will create a datasource that can be accessed like so:
    java:comp/env/jdbc/derby

    Hope this helps.

Viewing 3 posts - 1 through 3 (of 3 total)
Reply To: How To configure DB Connection Pool (from built-in tomcat6)?

You must be logged in to post in the forum log in