Shared Connection Pool via Singleton

I have just started to learn Java (more jsp & servlets) and have been going through "Core Servlets and Java Server Pages" and in there is stuff on connection pooling. The author provides a good a connection pool servlet that can be shared, but as I'm new and don't fully understand how everything works (got a basic idea).
How do i go about making the following code accessiable via a singleton class?
ConnectionPool Class
package sco;
import java.sql.*;
import java.util.*;
/** A class for preallocating, recycling, and managing
*  JDBC connections.
*  <P>
*  Taken from Core Servlets and JavaServer Pages
*  from Prentice Hall and Sun Microsystems Press,
*  http://www.coreservlets.com/.
*  &copy; 2000 Marty Hall; may be freely used or adapted.
public class ConnectionPool implements Runnable {
  private String driver, url, username, password;
  private int maxConnections;
  private boolean waitIfBusy;
  private Vector availableConnections, busyConnections;
  private boolean connectionPending = false;
  public ConnectionPool(String driver, String url,
                        String username, String password,
                        int initialConnections,
                        int maxConnections,
                        boolean waitIfBusy)
      throws SQLException {
    this.driver = driver;
    this.url = url;
    this.username = username;
    this.password = password;
    this.maxConnections = maxConnections;
    this.waitIfBusy = waitIfBusy;
    if (initialConnections > maxConnections) {
      initialConnections = maxConnections;
    availableConnections = new Vector(initialConnections);
    busyConnections = new Vector();
    for(int i=0; i<initialConnections; i++) {
      availableConnections.addElement(makeNewConnection());
  public synchronized Connection getConnection()
      throws SQLException {
    if (!availableConnections.isEmpty()) {
      Connection existingConnection =
        (Connection)availableConnections.lastElement();
      int lastIndex = availableConnections.size() - 1;
      availableConnections.removeElementAt(lastIndex);
      // If connection on available list is closed (e.g.,
      // it timed out), then remove it from available list
      // and repeat the process of obtaining a connection.
      // Also wake up threads that were waiting for a
      // connection because maxConnection limit was reached.
      if (existingConnection.isClosed()) {
        notifyAll(); // Freed up a spot for anybody waiting
        return(getConnection());
      } else {
        busyConnections.addElement(existingConnection);
        return(existingConnection);
    } else {
      // Three possible cases:
      // 1) You haven't reached maxConnections limit. So
      //    establish one in the background if there isn't
      //    already one pending, then wait for
      //    the next available connection (whether or not
      //    it was the newly established one).
      // 2) You reached maxConnections limit and waitIfBusy
      //    flag is false. Throw SQLException in such a case.
      // 3) You reached maxConnections limit and waitIfBusy
      //    flag is true. Then do the same thing as in second
      //    part of step 1: wait for next available connection.
      if ((totalConnections() < maxConnections) &&
          !connectionPending) {
        makeBackgroundConnection();
      } else if (!waitIfBusy) {
        throw new SQLException("Connection limit reached");
      // Wait for either a new connection to be established
      // (if you called makeBackgroundConnection) or for
      // an existing connection to be freed up.
      try {
        wait();
      } catch(InterruptedException ie) {}
      // Someone freed up a connection, so try again.
      return(getConnection());
  // You can't just make a new connection in the foreground
  // when none are available, since this can take several
  // seconds with a slow network connection. Instead,
  // start a thread that establishes a new connection,
  // then wait. You get woken up either when the new connection
  // is established or if someone finishes with an existing
  // connection.
  private void makeBackgroundConnection() {
    connectionPending = true;
    try {
      Thread connectThread = new Thread(this);
      connectThread.start();
    } catch(OutOfMemoryError oome) {
      // Give up on new connection
  public void run() {
    try {
      Connection connection = makeNewConnection();
      synchronized(this) {
        availableConnections.addElement(connection);
        connectionPending = false;
        notifyAll();
    } catch(Exception e) { // SQLException or OutOfMemory
      // Give up on new connection and wait for existing one
      // to free up.
  // This explicitly makes a new connection. Called in
  // the foreground when initializing the ConnectionPool,
  // and called in the background when running.
  private Connection makeNewConnection()
      throws SQLException {
    try {
      // Load database driver if not already loaded
      Class.forName(driver);
      // Establish network connection to database
      Connection connection =
        DriverManager.getConnection(url, username, password);
      return(connection);
    } catch(ClassNotFoundException cnfe) {
      // Simplify try/catch blocks of people using this by
      // throwing only one exception type.
      throw new SQLException("Can't find class for driver: " +
                             driver);
  public synchronized void free(Connection connection) {
    busyConnections.removeElement(connection);
    availableConnections.addElement(connection);
    // Wake up threads that are waiting for a connection
    notifyAll();
  public synchronized int totalConnections() {
    return(availableConnections.size() +
           busyConnections.size());
  /** Close all the connections. Use with caution:
   *  be sure no connections are in use before
   *  calling. Note that you are not <I>required</I> to
   *  call this when done with a ConnectionPool, since
   *  connections are guaranteed to be closed when
   *  garbage collected. But this method gives more control
   *  regarding when the connections are closed.
  public synchronized void closeAllConnections() {
    closeConnections(availableConnections);
    availableConnections = new Vector();
    closeConnections(busyConnections);
    busyConnections = new Vector();
  private void closeConnections(Vector connections) {
    try {
      for(int i=0; i<connections.size(); i++) {
        Connection connection =
          (Connection)connections.elementAt(i);
        if (!connection.isClosed()) {
          connection.close();
    } catch(SQLException sqle) {
      // Ignore errors; garbage collect anyhow
  public synchronized String toString() {
    String info =
      "ConnectionPool(" + url + "," + username + ")\n" +
      ", available=" + availableConnections.size() + "\n" +
      ", busy=" + busyConnections.size() + "\n" +
      ", max=" + maxConnections;
    return(info);
ScoPool Class (singleton to access the connection pool)
package sco;
public class ScoPool extends ConnectionPool {
  private ScoPool pool = null;
  private ScoPool() {
    super(); // Call parent constructor
  public static synchronized ScoPool getInstance() {
    if(pool == null) {
      pool = new ScoPool();
    return(pool);
}Please help a newbie.

Figured it out.
package sco;
import java.sql.SQLException;
public class ScoPool extends ConnectionPool {
  private static ScoPool pool;
  private ScoPool(String driver, String url, String username, String password,
                  int initialConnections, int maxConnections, boolean waitIfBusy) throws SQLException {
    super(driver, url, username, password, initialConnections, maxConnections, waitIfBusy); // Call parent constructor
  public static synchronized ScoPool getInstance() {
    if(pool == null) {
      String driver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
      String url = "jdbc:microsoft:sqlserver://MIM-W0432:1433;DatabaseName=sco";
      String username = "sco_user";
      String password = "123";
      int initCon = 5;
      int maxCon = 10;
      boolean waitIfBusy = true;
      try {
        pool = new ScoPool(driver, url, username, password, initCon, maxCon, waitIfBusy);
      catch(SQLException sqle) {
    return pool;
}

Similar Messages

  • BI Admin Tool - Setting connection pool via shell script - Is it possible?

    Hi,
    Here's the problem I am trying to solve.
    I am using a J2EE application that uses OBIEE for reporting.
    The *.rpd file is installed at a particular location when our J2EE product is installed.
    I then copy the *.rpd file to the BI home on a different server using a shell script.
    The shell script that deploys the *.rpd file does the following:
    1. Shuts down BI processes that are running
    2. Deletes the old *.rpd file
    3. Copies the new *.rpd file
    4. Starts all BI processes
    I am happy with the way we have automated this process, but would like to take it one step further.
    The *.rpd file does not have the connection pool hard-coded in it. And we want to keep it that way.
    What we would like to do is - pass the connection pool parameters to the shell script (that is used for *.rpd's deployment) and have it automatically update the *.rpd file. Is it possible to do this at all? How do we go about accomplishing this?
    Or in other words - Is there a way to update the connection pools WITHOUT hard-coding it in the *.rpd file or WITHOUT using the BI Administration Tool.
    Currently, we manually update the connection pools in the Physical Layer using the Oracle BI Administration Tool.
    The version of BI Administration Tool being used is 10.1.3.3.1 installed on a Microsoft Windows XP Professional SP2 machine. The BI Server itself is running on an Oracle Enterprise Linux 4.0 box.
    Do let me know if you need more information that would help answer this question.
    Thank you.

    Thank you - fiston and Gagan.
    I am going with fiston's solution - since it is easier to implement. I am on the QA team and the automated deployment is to lessen QA's deployment time.
    While one of our developer's said that she prefer's Gagan's solution - it would be over-kill to make changes to the application's schema for the said purpose.
    I will further make another post as to whether or not the automated deployment worked for us.

  • How to kill a Query In Shared Connection Pool

    Is it possible to kill just a single "long running query" (and in this case after 5 seconds) when the connection is through a connection pool?
    Environment is Exadata, about a 1500 Users making search query and may do a query for "THE%"
    Is there a profile setting?
    Regards

    This sounds like a perfect case for the Resource Manager, with which Exadata is very closely integrated.  Here is an example,
    http://www.orafaq.com/forum/mv/msg/121801/333625/0/#msg_333625

  • Sharing connection pooling  ?

    Is there a way to checkin the connection back to the pool and still have an access to the resultset in order to reuse the connection for other queries ?

    gnosis,
    You asked:
    Is there a way to checkin the connection back to the pool and still have
    access to the resultset in order to reuse the connection for other queries ?
    A single "Connection" object can be used to create (theoretically) an infinite number of "Statement" objects where each "Statement" has an associated "ResultSet".
    In other words, you don't need to release the "Connection" object in order to use it to perform a second query.
    You are asking the classic wrong question.
    Instead of asking, "How do I implement my proposed solution?", you should ask, "What is the best solution to my problem?"
    Your problem is that you want to have two (or more) "ResultSet"s opened simultaneously and you think the only way to do that is to release the "Connection", hence your question.
    A better question would be: "Can I have two 'ResultSet' objects opened simultaneously, using the same 'Connection'?"
    Now, why do you think you need two "ResultSet" objects opened simultaneously?
    Good Luck,
    Avi.

  • Recognizing alternate connection pool

    hi..
    Currently, If a connection pool fails due to a TNS failure, application instance also fails, it has lost connectivity.
    But I need, my application to recognize an alternate connection pool, such that if transactions time out on one connection, application would recognize that the primary pool is not responding and retry the transactions on a secondary data connection pool via the alternate DB instance.
    If I get the solution for this, it will be appreciable
    Thanks in advance
    Suresh

    Hi. Look at our documentation on multipools.
    Joe
    Suresh Kumar wrote:
    hi..
    Currently, If a connection pool fails due to a TNS failure, application instance also fails, it has lost connectivity.
    But I need, my application to recognize an alternate connection pool, such that if transactions time out on one connection, application would recognize that the primary pool is not responding and retry the transactions on a secondary data connection pool via the alternate DB instance.
    If I get the solution for this, it will be appreciable
    Thanks in advance
    Suresh

  • Connection pool with AS400

    Hello, i have a prob creating connection pool via AS "wizard"
    i've tried both com.ibm.as400.access.AS400JDBCDataSource and com.ibm.as400.access.AS400JDBCDriver
    both doesnt work for me...
    i have the following parameters:
    <property name="hibernate.connection.driver_class">com.ibm.as400.access.AS400JDBCDriver</property>
    <property name="hibernate.connection.password">xxxx</property>
    <property name="hibernate.connection.username">xxx</property>
    <property name="hibernate.connection.url">jdbc:as400://xx.xx.xx.xx</property>
    <property name="hibernate.default_schema">ssss</property>
    <property name="hibernate.default_catalog">ccccc</property>
    How do i configure these to Sun AS connection pool?
    Thank you in advance.

    You can refer :
    1) creating jdbc-connection-pool, jdbc-resource
    http://docs.sun.com/app/docs/doc/819-4733/6n6s6u1bn?a=view
    2) configuration for various database vendors
    http://docs.sun.com/app/docs/doc/819-3658/6n5s5nklk?a=view
    AS400 is not listed above, still it will work if the jdbc driver is jdbc-30 complaint.
    You need to provide "datasource-classname" and necessary parameters like user, password, URL, server, databasename etc.,
    Thanks,
    -Jagadish

  • Setting up connection pool for cloudscape 10 embedded database

    I got problem with setting connection pool via admin console for cloudscape 10 embedded in j2ee 1.4 (Application server 8.1), what im doing is:
    -in resources/jdbc/ConnectionPools i add a new pool
    - datasource classname i set up as: "org.apache.derby.jdbc.EmbeddedXADataSource"
    -resource type: "javax.sql.XADataSource"
    -DatabaseName: "jdbc:derby:D:\\Programowanie\J2EE\domains\domain1\config\notesData"
    -set no password and user, becouse i havet set this in database
    and when i ping to that datebase i got error:"Operation 'pingConnectionPool' failed in 'resources' Config Mbean."
    when i change Datasource Classname to: "org.apache.derby.jdbc.EmbeddedDataSource", this error occur:
    Operation 'pingConnectionPool' failed in 'resources' Config Mbean. Target exception message: Connection object cannot be null
    what im doing wrong? i look everywhere and i cant find solution to my problem...hope you can help me.
    Thanks,
    Krystian

    Amit wrote:
    >
    "whats are the settings (URL, driver, properties) required to set up a connection pool for DB2 on OS/390 ?I'm using "COM.ibm.db2.jdbc.app.DB2Driver" as DB2 driverHi. If you can successfully use that driver with one of it's simple
    JDBC example programs, then show me that example, at least the
    part that makes the connection, and I'll show you how to define a pool.
    Joe
    PS: Folks: BEA WebLogic is expanding rapidly, with both entry and advanced positions
    for people who want to work with Java, XML, SOAP and E-Commerce infrastructure products.
    We have jobs at Nashua NH, Liberty Corner NJ, San Francisco and San Jose CA.
    Send resumes to [email protected]

  • Running WL as NT Service is not Creating Connection  Pools?

    We have something very strange happening here. We recently installed Weblogic 6.1 sp 4 on an WinNT 2000 box and installed our application. We are connecting to an Oracle 8.1.7 database using the Oracle 8.1.7 client drivers. We configured our connection pool via the Web Console. We also installed our application to run as a NT Service using "beasvc.exe" utility.
    When we run our application after starting Weblogic from the commandline, our application runs fine. It creates the Oracle connection pool and everything is great.
    However when we run our application by starting it under the NT Services window, our application fails to start the connection pool. Looking at all the logs, I don't see and errors or exceptions being thrown. I did notice that the connection pool was not created. But again, no errors were thrown.
    Has anyone seen this behavior? To make things more confusing for me, this whole solution is working fine on another WinNT 2000 box with the only difference beint that we are using Weblogic 6.1 sp2. Anyone have any ideas??? Also, running the NT Service version of Weblogic in debug mode also worked!

    It takes the Oracle service quite a bit of time to start up. Make sure that you
    set up the DependsOnService correctly in your registry so that Oracle comes up
    fully before launching WL.
    Paul
    Clyde <[email protected]> wrote:
    We have something very strange happening here. We recently installed
    Weblogic 6.1 sp 4 on an WinNT 2000 box and installed our application.
    We are connecting to an Oracle 8.1.7 database using the Oracle 8.1.7
    client drivers. We configured our connection pool via the Web Console.
    We also installed our application to run as a NT Service using "beasvc.exe"
    utility.
    When we run our application after starting Weblogic from the commandline,
    our application runs fine. It creates the Oracle connection pool and
    everything is great.
    However when we run our application by starting it under the NT Services
    window, our application fails to start the connection pool. Looking
    at all the logs, I don't see and errors or exceptions being thrown.
    I did notice that the connection pool was not created. But again,
    no errors were thrown.
    Has anyone seen this behavior? To make things more confusing for me,
    this whole solution is working fine on another WinNT 2000 box with the
    only difference beint that we are using Weblogic 6.1 sp2. Anyone have
    any ideas??? Also, running the NT Service version of Weblogic in debug
    mode also worked!

  • Sun One Web Server connection pool goes stale after some time

    Hi all,
    I have a few web applications running on Sun One Web Server 6.1 (SP4). I configured a connection pool via the web admin of the web server. I do not know why the connections in the connection pool are never released after some time (this happened for 3 times with a couple of months in between). I need to reboot the web server to solve this problem everytime the connection pool goes stale. I have verified that the resources are released (stream and connection are closed) with proper programming logic. Even so, I think that the connections will be timed out (the setting is 5 minutes) by the web server as a bulletproof even if the resource is not released properly as implemented in the code logic. Can anybody help on this? I have been troubled by this problem by weeks.
    Thank you in advance.

    Hi all,
    I have a few web applications running on Sun One Web Server 6.1 (SP4). I configured a connection pool via the web admin of the web server. I do not know why the connections in the connection pool are never released after some time (this happened for 3 times with a couple of months in between). I need to reboot the web server to solve this problem everytime the connection pool goes stale. I have verified that the resources are released (stream and connection are closed) with proper programming logic. Even so, I think that the connections will be timed out (the setting is 5 minutes) by the web server as a bulletproof even if the resource is not released properly as implemented in the code logic. Can anybody help on this? I have been troubled by this problem by weeks.
    Thank you in advance.

  • Why would connection pooling cause problems with a trigger?

    This is a strange one. We have an app that deletes a row in a database table, and this table has a delete trigger on it. The row gets deleted every time the app is run, yet the trigger only fires intermittently. It's not that the trigger is failiing in some way - it just doesn't get called at all. If I issue the same delete command in PL/SQL developer then the trigger fires every time.
    Several hours later and out of desparation I tried turning off connection pooling via the app's connection string, and found that the trigger now fires every time. Any ideas what might be causing this behaviour? I can reproduce/fix the issue every time simply by setting "Pooling" to true or false!
    We are using Oracle 11g and ODP.Net v4.112.2.0.
    Thanks in advance
    Andrew

    More information: I've now been able to reproduce this issue in a small .Net app, and can make it fail in a more consistent manner (which I'll explain later). While it's still too large to post the entire code here, I can summarise what the app does in pseudo-code:-
    for(int i = 1; i <= 10; i++) // Run the test a number of times
    // Step 1 - Delete rows from the table with the delete query in question
    Execute non-query "delete from test_table";
    Wait 1 second
    // Step 2 - Check that the delete actually happened
    Execute reader "select count(*) from test_table"
    Display the count
    // Step 3 - Check that the delete trigger inserted some rows into a "logging" table. This is my method of "tracing" - I added a basic insert to the start of each trigger section, as mentioned in my previous post.
    Execute reader "select count(*) from my_logging_table"
    Display the count
    // Reinstate the test data
    Execute non-query "<insert rows back into test_table>"
    Wait 1 second
    For info the connection string is fairly basic:- "Data Source=<tns name>;User Id=<foo>;Password=<bar>"
    Some points of interest:-
    - When running the above test app, the trigger successfully fires on the very first iteration (i.e. "Step 3" displays a non-zero count from the logging table). All subsequent iterations fail ("Step 3" displays the same count each time).
    - If I turn off connection pooling (by adding "Pooling=false" to the connection string), the trigger runs on every iteration (i.e. "Step 3" displays an ever-incrementing record count).
    - Regardless of whether it works or fails, the deletion in step 1 does take place (confirmed by "Step 2" displaying a count of zero).
    - I added the waits after the non-query calls to see if that made a difference, but it doesn't. I can change these to 10 seconds or more and it will have no effect on the issue.
    The "Execute non-query" method uses code along these lines:-
    using (var conn = new OracleConnection(ConnString))
    conn.Open();
    using (var cmd = conn.CreateCommand())
    cmd.CommandText = sql;
    cmd.CommandType = CommandType.Text;
    result = cmd.ExecuteNonQuery();
    conn.Close();
    return result;
    While the "Execute reader" method looks like this:-
    var conn = new OracleConnection(ConnString);
    conn.Open();
    var cmd = conn.CreateCommand();
    cmd.CommandText = sql;
    cmd.CommandType = CommandType.Text;
    return cmd.ExecuteReader(CommandBehavior.CloseConnection);
    The calling code in the for loop, wraps the returned reader in a using clause like this:-
    using (var reader = ExecuteReader("<sql>"))
    This will dispose of the reader, which will in turn close/dispose the connection (due to the CommandBehavior.CloseConnection parameter passed to ExecuteReader).
    Interestingly, if the reader isn't disposed of then the problem becomes more intermittent (the trigger will fire perhaps 25% of the time). This is what's happening in our unit test harness. By ensuring the reader/connection is closed and disposed (which common sense would say should improve matters), the trigger only fires on the very first iteration of the loop. The plot thickens.

  • Is connection pooling and sharing available on Oracle 9i RDBMS ?

    Hello,
    I would like to connect from oracle to sql server through db link and ODBC (Heterogenous connectivity). But every session in oracle launch session in sql server. Is it possible to have connection pooling and sharing from Oracle RDBMS level ? I need one solution : when (for example) i run 100 sessions in Oracle i would like to see 10 sessions on sql server. I would like remain 90 sessions from oracle to be queued.
    I would mention that i was using Heterogenous connectivity with multithreading agent (agtctl) without success.
    appreciate any help :-)

    There are two concepts you could evaluate, but they are mainly used for connections to the database, not to sqlserver, but if you can make them work with heterogeneous connectivity this could help:
    Connection Pooling. When many sessions are connecting to the same database, it could be that some of them remain idle. Oracle can detect them and timed them out letting another session to enter into the database, letting the idle session remain open without closing its session. This is configured by means of the shared server architecture.
    Session Multiplexing. Session multiplexing allows the same bandwidth to be used by many sessions at the same time, this enables the server to use fewer network connection endpoints for incoming request. In order for you to configure session multiplexing you have to configure connection manager.
    Ref. Oracle® Database Net Services Administrator's Guide
    10g Release 2 (10.2)
    Part Number B14212-02
    ~ Madrid
    http://hrivera99.blogspot.com/

  • MacoBook Pro connecting wirelessly via Personal Web Sharing from iMac G5

    Subject line says it all... more specifically my problem is that some things seem "blocked" on the MBP when i'm connecting wirelessly via my iMac network, but then are 100% functional when I use other wireless networks.
    examples:
    • gmail via Mail.app [mailbox always has the ! symbol and says it's timed out]
    • playing app-based online games, certian functions will not work
    • using FTP software, it won't connect
    Maybe this an issue I can fix with port forwarding, if so how do I go about doing this? I was told my iMac is technically acting as a router, but I don't have a lot of experience with this type of networking. Thanks!
    iMac G5 2GHz • 15" MacBook Pro 2GHz   Mac OS X (10.4.9)  

    Personal Web Sharing can be a bit tricky and yes, it's because of the firewall on the Mac that's sharing its connection.
    The actual firewall software in the Mac is completely configurable, but the friendly user interface doesn't support the more sophisticated configurations. Fancier setups would require the use of commandline scripts run from Terminal.
    You'll save yourself a lot of headaches if you buy a wireless base station, and forget about using Personal Web Sharing. A $60 Linksys will do the job nicely.

  • Has anyone run the connection pooling for mysql & tomcat successfully?

    I'm trying to set up connection pooling. I'm following the how-to page at
    http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.html
    But when i test the DBTest/test.jsp file, tomcat displays an error =
    could not load jdbc driver class 'null'(msdos)
    i have placed all the required .jar files in the tomcat lib.
    below is the cofiguration i did to the server.xml file
    <!-- Example Server Configuration File -->
    <!-- Note that component elements are nested corresponding to their
    parent-child relationships with each other -->
    <!-- A "Server" is a singleton element that represents the entire JVM,
    which may contain one or more "Service" instances. The Server
    listens for a shutdown command on the indicated port.
    Note: A "Server" is not itself a "Container", so you may not
    define subcomponents such as "Valves" or "Loggers" at this level.
    -->
    <Server port="8005" shutdown="SHUTDOWN" debug="0">
    <!-- Uncomment these entries to enable JMX MBeans support -->
    <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"
    debug="0"/>
    <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"
    debug="0"/>
    <!-- Global JNDI resources -->
    <GlobalNamingResources>
    <!-- Test entry for demonstration purposes -->
    <Environment name="simpleValue" type="java.lang.Integer" value="30"/>
    <!-- Editable user database that can also be used by
    UserDatabaseRealm to authenticate users -->
    <Resource name="UserDatabase" auth="Container"
    type="org.apache.catalina.UserDatabase"
    description="User database that can be updated and saved">
    </Resource>
    <ResourceParams name="UserDatabase">
    <parameter>
    <name>factory</name>
    <value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
    </parameter>
    <parameter>
    <name>pathname</name>
    <value>conf/tomcat-users.xml</value>
    </parameter>
    </ResourceParams>
    </GlobalNamingResources>
    <!-- A "Service" is a collection of one or more "Connectors" that share
    a single "Container" (and therefore the web applications visible
    within that Container). Normally, that Container is an "Engine",
    but this is not required.
    Note: A "Service" is not itself a "Container", so you may not
    define subcomponents such as "Valves" or "Loggers" at this level.
    -->
    <!-- Define the Tomcat Stand-Alone Service -->
    <Service name="Tomcat-Standalone">
    <!-- A "Connector" represents an endpoint by which requests are received
    and responses are returned. Each Connector passes requests on to the
    associated "Container" (normally an Engine) for processing.
    By default, a non-SSL HTTP/1.1 Connector is established on port 8080.
    You can also enable an SSL HTTP/1.1 Connector on port 8443 by
    following the instructions below and uncommenting the second Connector
    entry. SSL support requires the following steps (see the SSL Config
    HOWTO in the Tomcat 4.0 documentation bundle for more detailed
    instructions):
    * Download and install JSSE 1.0.2 or later, and put the JAR files
    into "$JAVA_HOME/jre/lib/ext".
    * Execute:
    %JAVA_HOME%\bin\keytool -genkey -alias tomcat -keyalg RSA (Windows)
    $JAVA_HOME/bin/keytool -genkey -alias tomcat -keyalg RSA (Unix)
    with a password value of "changeit" for both the certificate and
    the keystore itself.
    By default, DNS lookups are enabled when a web application calls
    request.getRemoteHost(). This can have an adverse impact on
    performance, so you can disable it by setting the
    "enableLookups" attribute to "false". When DNS lookups are disabled,
    request.getRemoteHost() will return the String version of the
    IP address of the remote client.
    -->
    <!-- Define a non-SSL Coyote HTTP/1.1 Connector on port 8081 -->
    <Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
    port="8080" minProcessors="5" maxProcessors="75"
    enableLookups="true" redirectPort="8443"
    acceptCount="100" debug="0" connectionTimeout="20000"
    useURIValidationHack="false" disableUploadTimeout="true" />
    <!-- Note : To disable connection timeouts, set connectionTimeout value
    to -1 -->
    <!-- Define a SSL Coyote HTTP/1.1 Connector on port 8443 -->
    <!--
    <Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
    port="8443" minProcessors="5" maxProcessors="75"
    enableLookups="true"
         acceptCount="100" debug="0" scheme="https" secure="true"
    useURIValidationHack="false" disableUploadTimeout="true">
    <Factory className="org.apache.coyote.tomcat4.CoyoteServerSocketFactory"
    clientAuth="false" protocol="TLS" />
    </Connector>
    -->
    <!-- Define a Coyote/JK2 AJP 1.3 Connector on port 8009 -->
    <Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
    port="8009" minProcessors="5" maxProcessors="75"
    enableLookups="true" redirectPort="8443"
    acceptCount="10" debug="0" connectionTimeout="20000"
    useURIValidationHack="false"
    protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"/>
    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <!--
    <Connector className="org.apache.ajp.tomcat4.Ajp13Connector"
    port="8009" minProcessors="5" maxProcessors="75"
    acceptCount="10" debug="0"/>
    -->
    <!-- Define a Proxied HTTP/1.1 Connector on port 8082 -->
    <!-- See proxy documentation for more information about using this. -->
    <!--
    <Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
    port="8082" minProcessors="5" maxProcessors="75"
    enableLookups="true" disableUploadTimeout="true"
    acceptCount="100" debug="0" connectionTimeout="20000"
    proxyPort="80" useURIValidationHack="false" />
    -->
    <!-- Define a non-SSL legacy HTTP/1.1 Test Connector on port 8083 -->
    <!--
    <Connector className="org.apache.catalina.connector.http.HttpConnector"
    port="8083" minProcessors="5" maxProcessors="75"
    enableLookups="true" redirectPort="8443"
    acceptCount="10" debug="0" />
    -->
    <!-- Define a non-SSL HTTP/1.0 Test Connector on port 8084 -->
    <!--
    <Connector className="org.apache.catalina.connector.http10.HttpConnector"
    port="8084" minProcessors="5" maxProcessors="75"
    enableLookups="true" redirectPort="8443"
    acceptCount="10" debug="0" />
    -->
    <!-- An Engine represents the entry point (within Catalina) that processes
    every request. The Engine implementation for Tomcat stand alone
    analyzes the HTTP headers included with the request, and passes them
    on to the appropriate Host (virtual host). -->
    <!-- Define the top level container in our container hierarchy -->
    <Engine name="Standalone" defaultHost="localhost" debug="0">
    <!-- The request dumper valve dumps useful debugging information about
    the request headers and cookies that were received, and the response
    headers and cookies that were sent, for all requests received by
    this instance of Tomcat. If you care only about requests to a
    particular virtual host, or a particular application, nest this
    element inside the corresponding <Host> or <Context> entry instead.
    For a similar mechanism that is portable to all Servlet 2.3
    containers, check out the "RequestDumperFilter" Filter in the
    example application (the source for this filter may be found in
    "$CATALINA_HOME/webapps/examples/WEB-INF/classes/filters").
    Request dumping is disabled by default. Uncomment the following
    element to enable it. -->
    <!--
    <Valve className="org.apache.catalina.valves.RequestDumperValve"/>
    -->
    <!-- Global logger unless overridden at lower levels -->
    <Logger className="org.apache.catalina.logger.FileLogger"
    prefix="catalina_log." suffix=".txt"
    timestamp="true"/>
    <!-- Because this Realm is here, an instance will be shared globally -->
    <!-- This Realm uses the UserDatabase configured in the global JNDI
    resources under the key "UserDatabase". Any edits
    that are performed against this UserDatabase are immediately
    available for use by the Realm. -->
    <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
    debug="0" resourceName="UserDatabase"/>
    <!-- Comment out the old realm but leave here for now in case we
    need to go back quickly -->
    <!--
    <Realm className="org.apache.catalina.realm.MemoryRealm" />
    -->
    <!-- Replace the above Realm with one of the following to get a Realm
    stored in a database and accessed via JDBC -->
    <!--
    <Realm className="org.apache.catalina.realm.JDBCRealm" debug="99"
    driverName="org.gjt.mm.mysql.Driver"
    connectionURL="jdbc:mysql://localhost/authority"
    connectionName="test" connectionPassword="test"
    userTable="users" userNameCol="user_name" userCredCol="user_pass"
    userRoleTable="user_roles" roleNameCol="role_name" />
    -->
    <!--
    <Realm className="org.apache.catalina.realm.JDBCRealm" debug="99"
    driverName="oracle.jdbc.driver.OracleDriver"
    connectionURL="jdbc:oracle:thin:@ntserver:1521:ORCL"
    connectionName="scott" connectionPassword="tiger"
    userTable="users" userNameCol="user_name" userCredCol="user_pass"
    userRoleTable="user_roles" roleNameCol="role_name" />
    -->
    <!--
    <Realm className="org.apache.catalina.realm.JDBCRealm" debug="99"
    driverName="sun.jdbc.odbc.JdbcOdbcDriver"
    connectionURL="jdbc:odbc:CATALINA"
    userTable="users" userNameCol="user_name" userCredCol="user_pass"
    userRoleTable="user_roles" roleNameCol="role_name" />
    -->
    <!-- Define the default virtual host -->
    <Host name="localhost" debug="0" appBase="webapps"
    unpackWARs="true" autoDeploy="true">
    <Context path="/my-jsp" docBase="c:\JSP-Files" debug="0"
    privileged="true" reloadable="true" />
         <Context path="" docBase="c:\Inetpub\wwwroot" debug="0" privileged="true" />
    <Context path="/sharon" docBase="C:\Tomcat 4.1\webapps\sharon" debug="0" privileged="true" />
    <!-- Normally, users must authenticate themselves to each web app
    individually. Uncomment the following entry if you would like
    a user to be authenticated the first time they encounter a
    resource protected by a security constraint, and then have that
    user identity maintained across all web applications contained
    in this virtual host. -->
    <!--
    <Valve className="org.apache.catalina.authenticator.SingleSignOn"
    debug="0"/>
    -->
    <!-- Access log processes all requests for this virtual host. By
    default, log files are created in the "logs" directory relative to
    $CATALINA_HOME. If you wish, you can specify a different
    directory with the "directory" attribute. Specify either a relative
    (to $CATALINA_HOME) or absolute path to the desired directory.
    -->
    <!--
    <Valve className="org.apache.catalina.valves.AccessLogValve"
    directory="logs" prefix="localhost_access_log." suffix=".txt"
    pattern="common" resolveHosts="false"/>
    -->
    <!-- Logger shared by all Contexts related to this virtual host. By
    default (when using FileLogger), log files are created in the "logs"
    directory relative to $CATALINA_HOME. If you wish, you can specify
    a different directory with the "directory" attribute. Specify either a
    relative (to $CATALINA_HOME) or absolute path to the desired
    directory.-->
    <Logger className="org.apache.catalina.logger.FileLogger"
    directory="logs" prefix="localhost_log." suffix=".txt"
         timestamp="true"/>
    <!-- Define properties for each web application. This is only needed
    if you want to set non-default properties, or have web application
    document roots in places other than the virtual host's appBase
    directory. -->
    <!-- Tomcat Root Context -->
    <!--
    <Context path="" docBase="ROOT" debug="0"/>
    -->
    <!-- Tomcat Examples Context -->
    <Context path="/examples" docBase="examples" debug="0"
    reloadable="true" crossContext="true">
    <Logger className="org.apache.catalina.logger.FileLogger"
    prefix="localhost_DBTest_log." suffix=".txt"
    timestamp="true"/>
    <Ejb name="ejb/EmplRecord" type="Entity"
    home="com.wombat.empl.EmployeeRecordHome"
    remote="com.wombat.empl.EmployeeRecord"/>
    <!-- If you wanted the examples app to be able to edit the
    user database, you would uncomment the following entry.
    Of course, you would want to enable security on the
    application as well, so this is not done by default!
    The database object could be accessed like this:
    Context initCtx = new InitialContext();
    Context envCtx = (Context) initCtx.lookup("java:comp/env");
    UserDatabase database =
    (UserDatabase) envCtx.lookup("userDatabase");
    -->
    <!--
    <ResourceLink name="userDatabase" global="UserDatabase"
    type="org.apache.catalina.UserDatabase"/>
    -->
    <!-- PersistentManager: Uncomment the section below to test Persistent
              Sessions.
    saveOnRestart: If true, all active sessions will be saved
    to the Store when Catalina is shutdown, regardless of
    other settings. All Sessions found in the Store will be
    loaded on startup. Sessions past their expiration are
    ignored in both cases.
    maxActiveSessions: If 0 or greater, having too many active
    sessions will result in some being swapped out. minIdleSwap
    limits this. -1 means unlimited sessions are allowed.
    0 means sessions will almost always be swapped out after
    use - this will be noticeably slow for your users.
    minIdleSwap: Sessions must be idle for at least this long
    (in seconds) before they will be swapped out due to
    maxActiveSessions. This avoids thrashing when the site is
    highly active. -1 or 0 means there is no minimum - sessions
    can be swapped out at any time.
    maxIdleSwap: Sessions will be swapped out if idle for this
    long (in seconds). If minIdleSwap is higher, then it will
    override this. This isn't exact: it is checked periodically.
    -1 means sessions won't be swapped out for this reason,
    although they may be swapped out for maxActiveSessions.
    If set to >= 0, guarantees that all sessions found in the
    Store will be loaded on startup.
    maxIdleBackup: Sessions will be backed up (saved to the Store,
    but left in active memory) if idle for this long (in seconds),
    and all sessions found in the Store will be loaded on startup.
    If set to -1 sessions will not be backed up, 0 means they
    should be backed up shortly after being used.
    To clear sessions from the Store, set maxActiveSessions, maxIdleSwap,
    and minIdleBackup all to -1, saveOnRestart to false, then restart
    Catalina.
    -->
              <!--
    <Manager className="org.apache.catalina.session.PersistentManager"
    debug="0"
    saveOnRestart="true"
    maxActiveSessions="-1"
    minIdleSwap="-1"
    maxIdleSwap="-1"
    maxIdleBackup="-1">
    <Store className="org.apache.catalina.session.FileStore"/>
    </Manager>
              -->
    <Environment name="maxExemptions" type="java.lang.Integer"
    value="15"/>
    <Parameter name="context.param.name" value="context.param.value"
    override="false"/>
    <Resource name="jdbc/EmployeeAppDb" auth="SERVLET"
    type="javax.sql.DataSource"/>
    <Resource name="jdbc/TestDB"
         auth="Container"
         type="javax.sql.DataSource"/>
    <ResourceParams name="jdbc/TestDB">
    <parameter>
         <name>factory</name>
         <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
         </parameter>
         <!-- Maximum number of dB connections in pool. Make sure you
         configure your mysqld max_connections large enough to handle
         all of your db connections. Set to 0 for no limit.
         -->
         <parameter>
         <name>maxActive</name>
         <value>100</value>
         </parameter>
         <!-- Maximum number of idle dB connections to retain in pool.
         Set to 0 for no limit.
         -->
         <parameter>
         <name>maxIdle</name>
         <value>30</value>
         </parameter>
         <!-- Maximum time to wait for a dB connection to become available
         in ms, in this example 10 seconds. An Exception is thrown if
         this timeout is exceeded. Set to -1 to wait indefinitely.
         -->
         <parameter>
         <name>maxWait</name>
         <value>10000</value>
         </parameter>
    <!-- MySQL dB username and password for dB connections -->
    <parameter>
    <name>user</name>
    <value>javauser</value>
    </parameter>
    <parameter>
    <name>password</name>
    <value>javadude</value>
    </parameter>
    <!-- Class name for mm.mysql JDBC driver -->
    <parameter>
    <name>driverClassName</name>
    <value>org.gjt.mm.mysql.Driver</value>
    </parameter>
    <!-- The JDBC connection url for connecting to your MySQL dB.
         The autoReconnect=true argument to the url makes sure that the
         mm.mysql JDBC Driver will automatically reconnect if mysqld closed the
         connection. mysqld by default closes idle connections after 8 hours.
         -->
         <parameter>
         <name>url</name>
         <value>jdbc:mysql://localhost:3306/javatest?autoReconnect=true</value>
    </parameter>
    </ResourceParams>
    <Resource name="mail/Session" auth="Container"
    type="javax.mail.Session"/>
    <ResourceParams name="mail/Session">
    <parameter>
    <name>mail.smtp.host</name>
    <value>localhost</value>
    </parameter>
    </ResourceParams>
    <ResourceLink name="linkToGlobalResource"
    global="simpleValue"
    type="java.lang.Integer"/>
    </Context>
    </Host>
    </Engine>
    </Service>
    <!-- The MOD_WEBAPP connector is used to connect Apache 1.3 with Tomcat 4.0
    as its servlet container. Please read the README.txt file coming with
    the WebApp Module distribution on how to build it.
    (Or check out the "jakarta-tomcat-connectors/webapp" CVS repository)
    To configure the Apache side, you must ensure that you have the
    "ServerName" and "Port" directives defined in "httpd.conf". Then,
    lines like these to the bottom of your "httpd.conf" file:
    LoadModule webapp_module libexec/mod_webapp.so
    WebAppConnection warpConnection warp localhost:8008
    WebAppDeploy examples warpConnection /examples/
    The next time you restart Apache (after restarting Tomcat, if needed)
    the connection will be established, and all applications you make
    visible via "WebAppDeploy" directives can be accessed through Apache.
    -->
    <!-- Define an Apache-Connector Service -->
    <!--
    <Service name="Tomcat-Apache">
    <Connector className="org.apache.catalina.connector.warp.WarpConnector"
    port="8008" minProcessors="5" maxProcessors="75"
    enableLookups="true" appBase="webapps"
    acceptCount="10" debug="0"/>
    <Engine className="org.apache.catalina.connector.warp.WarpEngine"
    name="Apache" debug="0">
    <Logger className="org.apache.catalina.logger.FileLogger"
    prefix="apache_log." suffix=".txt"
    timestamp="true"/>
    <Realm className="org.apache.catalina.realm.MemoryRealm" />
    </Engine>
    </Service>
    -->
    </Server>
    Pleas4 help!!!

    you have your driver jar in Tomcat\common\lib?
    if so, check your classpath, it could be that.

  • Urgent...Help Needed.1. Helper Class 2. Connection Pool

    Hello,
    1. There are few helper classes which has to be
    shared b/w session and entity beans. But it
    seems,state of the object is not transfered to entity
    bean though the class has implemented Serializable
    interface. I have archived all the helper class and
    copied to j2ee\home\lib directory. The same jar file
    is made accessible to server via updating <library-
    path> in j2ee/home/config/application.xml file.
    2. How can i utilise connection pooling in oc4j. In data-sources.xml, i am using
    "OracleConnectionPoolDataSource" class. But i feel that connection pool is not utilised coz server hangs in the middle of the retrieval.
    The value of max-connections is 50.
    We are actually migrating from Weblogic 5.1.0 to Oracle 9i AS. In weblogic, we had given 10 max connections in weblogic.properties,it is working fine. But i dont understand why it is not working in 9i AS though the max-connections is 50.
    Kindly let me know the solution at the earliest as it is very urgent to get the program running...
    Thanx and Regards,
    Achyuth

    Hi,
    hopefully I can help you.
    1. There are few helper classes which has to be ...We have just the same constellation. We have put the HelperClasses in the
    J2EE/home/lib dir, NOT specifying it in the application.xml. So everything works fine.
    The only thing: never, again: never put these files within WEB-INF and the lib-dir.
    With the HelperClasses in both we have only faced massive problems, mostly ClasCastExceptions.
    We had once all the helperClasses within J2EE/home/applications/lib, but this requires to
    specify this dir within the orion-application.xml within the appl dir in applications-deployment.
    It also worked fine.
    2. How can i utilise connection pooling in oc4j. In data-sources.xml, i am using ...I'm not sure of this, but I think, the container handles Connection Pooling, no matter what Factory you
    specify. But I think, the Class hasn't to be OracleConnectionPool ... but I have to check this (right now
    I have no access to our datasource.xml ..)
    cu
    ed

  • How to use connection pooling in jsp?

    I'm new to world of JSP. I'm developing web application using Oracle 8i and JSP to implement it. I'm using jakarta-tomcat server for this purpose.
    I'll frequently access the database. so I want to use the connection pooling.
    Can anybody explain the simple procedure to use it
    thanx

    Hello syyuen,
    Please help me, here iam sending u my server.xml , web.xml and servlet
    application. I put classes12.jar in tomcat/common/lib. and above servlet
    class application under tomcat/webapps/root/web-inf/classes
    and this is a simple servlet program for getting connection from the
    connection pool of tomcat using tyrex..
    my oracle database name is "myuser" and password is "mypass"
    either u check my server.xml or tell me where under which tag should i
    place <Resource...> tag in server.xml and should i need to modify any
    other places..??
    server.xml
    <Server port="8005" shutdown="SHUTDOWN" debug="0">
              <!-- Tomcat Stand-Alone Service -->
    <Service name="Tomcat-Standalone">
         <!-- Non-SSL HTTP/1.1 Connector on port 8080 -->
    <Connector className="org.apache.catalina.connector.http.HttpConnector"
    port="8080" minProcessors="5" maxProcessors="75"
    enableLookups="true" redirectPort="8443"
    acceptCount="10" debug="0" connectionTimeout="60000"/>
              <!-- AJP 1.3 Connector on port 8009 -->
    <Connector className="org.apache.ajp.tomcat4.Ajp13Connector"
    port="8009" minProcessors="5" maxProcessors="75"
    acceptCount="10" debug="0"/>
              <!-- Top level container in our container hierarchy -->
    <Engine name="Standalone" defaultHost="localhost" debug="0">
         <!-- Global logger unless overridden at lower levels -->
    <Logger className="org.apache.catalina.logger.FileLogger"
    prefix="catalina_log." suffix=".txt"
    timestamp="true"/>
         <!-- Because this Realm is here, an instance will be shared globally
              <Realm className="org.apache.catalina.realm.MemoryRealm" /> -->
                   <!-- Replace the above Realm with one of the following to get a Realm
                   stored in a database and accessed via JDBC -->
                   <!-- <Realm className="org.apache.catalina.realm.JDBCRealm" debug="99"
                        driverName="org.gjt.mm.mysql.Driver"
                        connectionURL="jdbc:mysql://localhost/authority?user=test;password=test"
                        userTable="users" userNameCol="user_name" userCredCol="user_pass"
                        userRoleTable="user_roles" roleNameCol="role_name" />
                   -->
    <Realm className="org.apache.catalina.realm.JDBCRealm" debug="99"
              driverName="oracle.jdbc.driver.OracleDriver"
                   connectionURL="jdbc:oracle:thin:@oracle:1521:ORCL"
    connectionName = "mail"
    connectionPassword = "mail"
              userTable="users" userNameCol="user_name" userCredCol="user_pass"
                   userRoleTable="user_roles" roleNameCol="role_name" />
                        <!-- <Realm className="org.apache.catalina.realm.JDBCRealm" debug="99"
                        driverName="sun.jdbc.odbc.JdbcOdbcDriver"
                        connectionURL="jdbc:odbc:CATALINA"
                        userTable="users" userNameCol="user_name" userCredCol="user_pass"
                        userRoleTable="user_roles" roleNameCol="role_name" />
                        -->
                   <!-- Define the default virtual host -->
    <Host name="localhost" debug="1" appBase="webapps" unpackWARs="true">
         <Valve className="org.apache.catalina.valves.AccessLogValve"
         directory="logs" prefix="localhost_access_log." suffix=".txt"
         pattern="common"/>
    <Logger className="org.apache.catalina.logger.FileLogger"
    directory="logs" prefix="localhost_log." suffix=".txt"
         timestamp="true"/>
                   <!-- Tomcat Root Context -->
                   <!-- <Context path="" docBase="ROOT" debug="0"/> -->
                   <!-- Tomcat Manager Context -->
    <Context path="/manager" docBase="manager" debug="0" privileged="true"/>
    <!-- MY CONTEXT HERE -->
         <Context path="/localhost" docBase="localhost" debug="0" reloadable="false" override="true">
              <Resource name="jdbc/myConnection" auth="SERVLET" type="javax.sql.DataSource"/>
              <ResourceParams name="jdbc/myConnection">
                   <parameter><name>user</name><value>myuser</value></parameter>
                   <parameter><name>password</name><value>mypass</value></parameter>
                   <parameter><name>driverClassName</name><value>oracle.jdbc.driver.OracleDriver</value></parameter>
                   <parameter>
                        <name>url</name>
                        <value>jdbc:oracle:thin:@oracle:1521:ORCL</value>
                   </parameter>
                   <parameter>
                        <name>maxActive</name>
                        <value>32</value>
                   </parameter>
                   <parameter>
                        <name>maxIdle</name>
                        <value>10</value>
                   </parameter>
              </ResourceParams>
    <!-- END OF MY Context, Oracle username=myuser,password=mypass -->
    <!-- i pasted this context from somebody . should i need whole context or resource name in that...???? -->
    <!-- Tomcat Examples Context
    <Context path="/examples" docBase="examples" debug="0" reloadable="true" crossContext="true">
    -->
    <!--
    <Logger className="org.apache.catalina.logger.FileLogger" prefix="localhost_examples_log." suffix=".txt" timestamp="true"/>
         <Ejb name="ejb/EmplRecord" type="Entity" home="com.wombat.empl.EmployeeRecordHome" remote="com.wombat.empl.EmployeeRecord"/>
    <Environment name="maxExemptions" type="java.lang.Integer" value="15"/>
    <Parameter name="context.param.name" value="context.param.value" override="false"/>
    <Resource name="jdbc/EmployeeAppDb" auth="SERVLET" type="javax.sql.DataSource"/>
    <ResourceParams name="jdbc/EmployeeAppDb">
    <parameter><name>user</name><value>sa</value></parameter>
    <parameter><name>password</name><value></value></parameter>
    <parameter><name>driverClassName</name><value>org.hsql.jdbcDriver</value></parameter>
    <parameter><name>driverName</name><value>jdbc:HypersonicSQL:database</value></parameter>
    </ResourceParams>
    <Resource name="mail/Session" auth="Container" type="javax.mail.Session"/>
    <ResourceParams name="mail/Session">
    <parameter>
    <name>mail.smtp.host</name>
    <value>localhost</value>
    </parameter>
    </ResourceParams>
    -->
    </Context>
    </Host>
    </Engine>
    </Service>
         <!-- Define an Apache-Connector Service -->
    <Service name="Tomcat-Apache">
    <Connector className="org.apache.catalina.connector.warp.WarpConnector"
    port="8008" minProcessors="5" maxProcessors="75"
    enableLookups="true" appBase="webapps"
    acceptCount="10" debug="0"/>
                   <!-- Replace "localhost" with what your Apache "ServerName" is set to -->
    <Engine className="org.apache.catalina.connector.warp.WarpEngine"
    name="Apache" debug="0">
                   <!-- Global logger unless overridden at lower levels -->
    <Logger className="org.apache.catalina.logger.FileLogger"
    prefix="apache_log." suffix=".txt"
    timestamp="true"/>
                   <!-- Because this Realm is here, an instance will be shared globally -->
    <Realm className="org.apache.catalina.realm.MemoryRealm" />
    </Engine>
    </Service>
    </Server>
    web.xml
    <web-app>
    <servlet>
    <servlet-name>conServlet</servlet-name>
    <servlet-class>conServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>conServlet</servlet-name>
    <url-pattern> /conServlet </url-pattern>
    </servlet-mapping>
    <resource-ref>
    <description> Resource reference to java.sql.Connection
    factory defined in server.xml
    </description>
    <res-ref-name>jdbc/myConnection</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>
    </web-app>
    servlet application
    DataSource ds = (DataSource) new InitialContext().lookup("java:comp/env/jdbc/myConnection");
    conn = ds.getConnection();
    out.println("conn : " + conn);

Maybe you are looking for

  • Can someone pleas tell me about abap, java and xslt mappings

    Hi, can someone please tell me about abap, java and xslt mappings. Thanks, Bernard.

  • Joining Line Segments in CS6

    I am drawing a simple diamond shape made with one rectanlge shape and multiple line segments.  As I drew the design, I made sure to connect all the segments at the anchors.  When I select all of the segments and try to join the paths, the end points

  • PC doesn't connect to internet.

    I have a wireless network set up at home from my Apple Extreme Base station with no problem to both wireless Macs and a Dell Inspiron 5160. I just purchased a Dell XPS M170 and it see's network and says it's connected but hangs and does not connect t

  • Problem with IOS8 update and my 2013 Honda Accord

    Updated my iPod touch with IOS8 and now it acts weird while connected to the stereo of my 2013 Honda Accord with a USB cable.  When I start the car and set the stereo to iPod, it will grab a random song from the iTunes Library and start playing it. 

  • Performance cfif vs cfswitch

    With cfswitch code is more readable so no dought it should be used. But I am wondering if using cfswitch improves/affects performance of website or no? thanks