Connection pooling  in Tomcat

Hello all,
I've been using tomcat 5.0.27 and for quite sometime now using the connection pooling on tomcat as well.
I configure DataSource(no.of connections,username, password etc) by logging into tomcat admin console.
But what I've seen is it adds datasource configuration data into server.xml - including the username and password to the database(which will be supplied to the driver by the container when creating a connection). But I don't want the username and password to be present in the xml file (i.e. in clear text format). Is it possible to somehow give the password and the username when requesting for a connection i.e. datasource.getConnection and not while configuring the pool and still get it working?
Please guide me.
Thanks,

Oh yeah. I've already tried it. It always seems to
get the connection with the credentials that I gave
while configuring the datasource. Whatever password I
pass in the call to getConnection - it is being
ignored.Do you have one already set in the server.xml? If so, try removing it (and restarting the server).
But an implication - the server might just decide to
have say x connections in the pool on startup. So if
you havent given the uname/password for the
database(when you configured the datasource) and give
the credentials only when getConnection is called in
your code - how will the server have those x
connections in the pool on startup?Probably won't It may wait to store the connections to the pool until x number of calls to the getConnection method are made (like a lazy initialization). But I don't know, just getting around to testing now.
I have people telling me that having uname/password to
the database in server.xml doesn't augur well for the
security of data in the db :(It could be true, but
1) The only people to see the server.xml are those who work on the server. The server.xml (or better the context.xml if you can avoid editing the server.xml altogether) is not accessable from the web.
2) My strategy was always to create many different levels of access to any particular database. Some with Read Only access and limited table viewability, and then progressively higher access. You give the server.xml only the access they absolutely need. IE, if they are just retrieving data from a couple tables, make a read-only user with the ability to see only those tables...
Don't take my word for it though. I have never really tried to do the whole ultra-secure thing, my apps are not important.

Similar Messages

  • Database connection Pooling in TOMCAT

    I am trying Database connection Pooling in TOMCAT
    I am getting the following error
    org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'
    My Web.xml in $CATALINA_HOME\conf\web.xml
    <resource-ref>
    <res-ref-name>WMSPREF</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>
    and my server.xml in
    $CATALINA_HOME\conf\server.xml
    <ResourceParams name="WMSPREF">
    <parameter>
    <name>factory</name>
    <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
    </parameter>
    <parameter>
    <name>driverClassName</name>
    <value>oracle.jdbc.driver.OracleDriver</value>
    </parameter>
    <parameter>
    <name>url</name>
    <value>jdbc:oracle:thin:@10.94.100.148:1521:WMSPREF</value>
    </parameter>
    <parameter>
    <name>username</name>
    <value>wmsmigrate</value>
    </parameter>
    <parameter>
    <name>password</name>
    <value>abnwms</value>
    </parameter>
    <parameter>
    <name>maxActive</name>
    <value>20</value>
    </parameter>
    <parameter>
    <name>maxIdle</name>
    <value>10</value>
    </parameter>
    <parameter>
    <name>maxWait</name>
    <value>-1</value>
    </parameter>
    </ResourceParams>
    And my database.jsp : code
         Context ctx = new InitialContext();
         Context envContext = (Context)ctx.lookup("java:comp/env");
         DataSource ds = (DataSource)envContext.lookup("WMSPREF");
         conn = ds.getConnection();

    What version of Tomcat do you have? 4? 5? 5.5?
    Have you defined a Resource entry in server.xml as well as the ResourceParams?
    I have never had any luck configuring a datasource in the server.xml file.
    What HAS worked for me is putting the config into a myWebApp.xml file.
    My web context is "myWebApp"
    The name of the file is "myWebApp.xml"
    For Tomcat4 for this goes in the webapps directory
    For Tomcat5 this goes in the [TOMCAT_HOME]/conf/Catalina/localhost directory
    <?xml version='1.0' encoding='utf-8'?>
    <Context path="/myWebApp" docBase="myWebApp" debug="1" reloadable="true" crossContext="true" >
    <Resource name="WMSPREF" auth="Container"
                  type="javax.sql.DataSource">
    </Resource>
    <ResourceParams name="WMSPREF">
    <parameter>
      <name>factory</name>
      <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
    </parameter>
    <parameter>
      <name>driverClassName</name>
      <value>oracle.jdbc.driver.OracleDriver</value>
    </parameter>
    <parameter>
      <name>url</name>
      <value>jdbc:oracle:thin:@10.94.100.148:1521:WMSPREF</value>
    </parameter>
    <parameter>
      <name>username</name>
      <value>wmsmigrate</value>
    </parameter>
    <parameter>
      <name>password</name>
      <value>abnwms</value>
    </parameter>
    <parameter>
      <name>maxActive</name>
      <value>20</value>
    </parameter>
    <parameter>
      <name>maxIdle</name>
      <value>10</value>
    </parameter>
    <parameter>
      <name>maxWait</name>
      <value>-1</value>
    </parameter>
    </ResourceParams>
    </Context>Cheers,
    evnafets

  • How to create connection pooling in Tomcat 5.0

    present i am developing one web site in that i am using tomcat 5.0
    i am trying to establish connection pooling in tomcat,i am facing some problems..
    tomcat throws the following exception ie.,
    cannot create JDBC Driver class for connect URL null.
    my code lik this
    i configured the web.xml
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <web-app>
    <resource-ref>
    <description>Oracle Datasource example</description>
    <res-ref-name>sqlserver</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>
    </web-app>
    my server.xml
    <?xml version='1.0' encoding='utf-8'?>
    <Server>
    <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"/>
    <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
    <GlobalNamingResources>
    <Environment name="simpleValue" type="java.lang.Integer" value="30"/>
    <Resource auth="Container" description="User database that can be updated and saved" name="UserDatabase" type="org.apache.catalina.UserDatabase"/>
    <Resource auth="Container" name="sqlserver" type="javax.sql.DataSource"/>
    <ResourceParams name="UserDatabase">
    <parameter>
    <name>factory</name>
    <value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
    </parameter>
    <parameter>
    <name>password</name>
    <value>sudha</value>
    </parameter>
    <parameter>
    <name>pathname</name>
    <value>conf/tomcat-users.xml</value>
    </parameter>
    <parameter>
    <name>username</name>
    <value>sudha</value>
    </parameter>
    </ResourceParams>
    <ResourceParams name="sqlserver">
    <parameter>
    <name>url</name>
    <value>jdbc:odbc:SQL</value>
    </parameter>
    <parameter>
    <name>validationQuery</name>
    <value>select * from employee</value>
    </parameter>
    <parameter>
    <name>maxIdle</name>
    <value>4</value>
    </parameter>
    <parameter>
    <name>maxActive</name>
    <value>8</value>
    </parameter>
    <parameter>
    <name>driverClassName</name>
    <value>sun.jdbc.odbc.JdbcOdbcDriver</value>
    </parameter>
    <parameter>
    <name>maxWait</name>
    <value>5000</value>
    </parameter>
    <parameter>
    <name>username</name>
    <value>kpi</value>
    </parameter>
    <parameter>
    <name>factory</name>
    <value>org.apache.naming.factory.DbcpDataSourceFactory</value>
    </parameter>
    <parameter>
    <name>password</name>
    <value>kpi</value>
    </parameter>
    </ResourceParams>
    </GlobalNamingResources>
    <Service name="Catalina">
    <Connector acceptCount="100" connectionTimeout="20000" disableUploadTimeout="true" port="8080" redirectPort="8443" maxSpareThreads="75" maxThreads="150" minSpareThreads="25">
    </Connector>
    <Connector port="8009" protocol="AJP/1.3" protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler" redirectPort="8443">
    </Connector>
    <Engine defaultHost="localhost" name="Catalina">
    <Host appBase="webapps" name="localhost">
    <Logger className="org.apache.catalina.logger.FileLogger" prefix="localhost_log." suffix=".txt" timestamp="true"/>
    </Host>
    <Logger className="org.apache.catalina.logger.FileLogger" prefix="catalina_log." suffix=".txt" timestamp="true"/>
    <Realm className="org.apache.catalina.realm.UserDatabaseRealm"/>
    </Engine>
    </Service>
    </Server>
    and i studied the the tomcat documentation in that tomcat mentioned
    The configuration properties for Tomcat's standard data source resource factory (org.apache.naming.factory.DbcpDataSourceFactory) are as follows:
    driverClassName - Fully qualified Java class name of the JDBC driver to be used.
    maxActive - The maximum number of active instances that can be allocated from this pool at the same time.
    maxIdle - The maximum number of connections that can sit idle in this pool at the same time.
    maxWait - The maximum number of milliseconds that the pool will wait (when there are no available connections) for a connection to be returned before throwing an exception.
    password - Database password to be passed to our JDBC driver.
    url - Connection URL to be passed to our JDBC driver. (For backwards compatibility, the property driverName is also recognized.)
    user - Database username to be passed to our JDBC driver.
    validationQuery - SQL query that can be used by the pool to validate connections before they are returned to the application. If specified, this query MUST be an SQL SELECT statement that returns at least one row.
    how to configure server.xml file
    and how to get the org.apache.naming.factory.DbcpDataSourceFactory
    please help me...this module is very very urgen to me..

    http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.html

  • How to create Connection pool in Tomcat 5

    present i am developing one web site in that i am using tomcat 5.
    i am trying to establish connection pooling in tomcat,i am facing some problems..
    tomcat throws the following exception ie.,
    cannot create JDBC Driver class for connect URL null.
    my code lik this
    i configured the web.xml
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <web-app>
    <resource-ref>
    <description>Oracle Datasource example</description>
    <res-ref-name>sqlserver</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>
    </web-app>
    my server.xml
    <?xml version='1.0' encoding='utf-8'?>
    <Server>
    <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"/>
    <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
    <GlobalNamingResources>
    <Environment name="simpleValue" type="java.lang.Integer" value="30"/>
    <Resource auth="Container" description="User database that can be updated and saved" name="UserDatabase" type="org.apache.catalina.UserDatabase"/>
    <Resource auth="Container" name="sqlserver" type="javax.sql.DataSource"/>
    <ResourceParams name="UserDatabase">
    <parameter>
    <name>factory</name>
    <value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
    </parameter>
    <parameter>
    <name>password</name>
    <value>sudha</value>
    </parameter>
    <parameter>
    <name>pathname</name>
    <value>conf/tomcat-users.xml</value>
    </parameter>
    <parameter>
    <name>username</name>
    <value>sudha</value>
    </parameter>
    </ResourceParams>
    <ResourceParams name="sqlserver">
    <parameter>
    <name>url</name>
    <value>jdbc:odbc:SQL</value>
    </parameter>
    <parameter>
    <name>validationQuery</name>
    <value>select * from employee</value>
    </parameter>
    <parameter>
    <name>maxIdle</name>
    <value>4</value>
    </parameter>
    <parameter>
    <name>maxActive</name>
    <value>8</value>
    </parameter>
    <parameter>
    <name>driverClassName</name>
    <value>sun.jdbc.odbc.JdbcOdbcDriver</value>
    </parameter>
    <parameter>
    <name>maxWait</name>
    <value>5000</value>
    </parameter>
    <parameter>
    <name>username</name>
    <value>kpi</value>
    </parameter>
    <parameter>
    <name>factory</name>
    <value>org.apache.naming.factory.DbcpDataSourceFactory</value>
    </parameter>
    <parameter>
    <name>password</name>
    <value>kpi</value>
    </parameter>
    </ResourceParams>
    </GlobalNamingResources>
    <Service name="Catalina">
    <Connector acceptCount="100" connectionTimeout="20000" disableUploadTimeout="true" port="8080" redirectPort="8443" maxSpareThreads="75" maxThreads="150" minSpareThreads="25">
    </Connector>
    <Connector port="8009" protocol="AJP/1.3" protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler" redirectPort="8443">
    </Connector>
    <Engine defaultHost="localhost" name="Catalina">
    <Host appBase="webapps" name="localhost">
    <Logger className="org.apache.catalina.logger.FileLogger" prefix="localhost_log." suffix=".txt" timestamp="true"/>
    </Host>
    <Logger className="org.apache.catalina.logger.FileLogger" prefix="catalina_log." suffix=".txt" timestamp="true"/>
    <Realm className="org.apache.catalina.realm.UserDatabaseRealm"/>
    </Engine>
    </Service>
    </Server>
    and i studied the the tomcat documentation in that tomcat mentioned
    The configuration properties for Tomcat's standard data source resource factory (org.apache.naming.factory.DbcpDataSourceFactory) are as follows:
    driverClassName - Fully qualified Java class name of the JDBC driver to be used.
    maxActive - The maximum number of active instances that can be allocated from this pool at the same time.
    maxIdle - The maximum number of connections that can sit idle in this pool at the same time.
    maxWait - The maximum number of milliseconds that the pool will wait (when there are no available connections) for a connection to be returned before throwing an exception.
    password - Database password to be passed to our JDBC driver.
    url - Connection URL to be passed to our JDBC driver. (For backwards compatibility, the property driverName is also recognized.)
    user - Database username to be passed to our JDBC driver.
    validationQuery - SQL query that can be used by the pool to validate connections before they are returned to the application. If specified, this query MUST be an SQL SELECT statement that returns at least one row.
    how to configure server.xml file
    and how to get the org.apache.naming.factory.DbcpDataSourceFactory
    please help me...this module is very very urgen to me..

    I spent many hours when i first implemented connection pooling trying to put it together. The information is scattered and the config has changed slightly from 5.0 to 5.5 etc. This is how I got it working in 5.5.17:
    * server.xml seems to be a wrong place for the pool configuration if you consider it to be an application specific thing. It might be a better idea to put it into C:\tomcat55\conf\Catalina\localhost\ConfigFileForYourWeapp.xml as follows:
    <Context path="/ClientLink" docBase="C:\eclipseWorkspace\PortfolioUI3\WebRoot">
          <Resource name="jdbc/testportfolios" auth="Container"
                         type="javax.sql.DataSource"
                         factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
                         username="****" password="******"
                         driverClassName="com.mysql.jdbc.Driver"
                         url="jdbc:mysql://192.168.0.101:3306/testportfolios?user=***********&password=***********&useUnicode=true&characterSet=swedish"
                         maxWait="10000" maxActive="30" maxIdle="10" removeAbandoned="true"
                         removeAbandonedTimeout="60" logAbandoned="true" testWhileIdle="true"
                         minEvictableIdleTimeMillis="4000"
                         timeBetweenEvictionRunsMillis="60000" validationQuery="SELECT '1'" />
          </Context>* Then add the following snippet into web.xml in your webapp directory:
    <resource-ref>
                    <description>Database pool defined in ClientLink.xml</description>
                    <res-ref-name>jdbc/testportfolios</res-ref-name>
                    <res-type>javax.sql.DataSource</res-type>
                    <res-auth>Container</res-auth>
               </resource-ref>* Next put the jdbc-driver jar in a place where tomcat can find it. That is common\lib. Note that the shared/lib does not work.
    * Get connections in java as follows:
                    try {
                         Context initCtx = new InitialContext();
                         DataSource ds = (DataSource) initCtx.lookup("java:comp/env/jdbc/testportfolios");
                         this.connection = ds.getConnection();
                    } catch (NamingException e) {
                         throw new RuntimeException("Java naming exception when getting connection from tomcat pool: " + e.getMessage());
                    }I hope that this helps you to save the time I lost figuring this out!
    Message was edited by:
    Tomppu

  • Connection Pooling in Tomcat 4.1.18

    Hi,
    Can anyone point me to a decent resource on how to implement Oracle connection pooling in Tomcat? I'm using the UltraSearch API's for an application and cannot get it to work correctly with the DBCP implementation that I currently use.
    Many thanks,
    Mark.

    Mark,
    What kind of Oracle Connection pooling are your refering to? Are you talking about BC4J connection pooling?

  • Connection pool + db2 + tomcat 5 migration problem

    I succeded in using connection pooling in Tomcat 4.0.x and IBM db2 6.xx and 7.xx.
    Now I am trying to use Tomcat 5 (released with netbeans 3.6) and I have some problems.
    I migrated the context information from server xml to context xml, but I have a username-password problem
    <Context docBase="D:\j2sdk_nb\NetBeans3.6\progetti\Pegaso2" path="/pegaso2" reloadable="true">
    <Resource auth="Container" name="jdbc/pegaso61" type="javax.sql.DataSource"/>
    <ResourceParams name="jdbc/pegaso61">
    <parameter>
    <name>factory</name>
    <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
    </parameter>
    <parameter>
    <name>driverClassName</name>
    <value>COM.ibm.db2.jdbc.app.DB2Driver</value>
    </parameter>
    <parameter>
    <name>url</name>
    <value>jdbc:db2:pegaso61</value>
    </parameter>
    <parameter>
    <name>username</name>
    <value>userxxxx</value>
    </parameter>
    <parameter>
    <name>password</name>
    <value>passxxxx</value>
    </parameter>
    </ResourceParams>
    </Context>
    When running my servlets, i get this error:
    Exception in PoolDB2Connector.getConnection():org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory, cause: [IBM][CLI Driver] SQL1403N The username and/or password supplied is incorrect. SQLSTATE=08004
    So it means ( I think !!) that the web-application i getting the right driver ( i got a db2 error) but is having problem with username and password.
    I am using getConnection() method ( with no argouments) in my PoolDB2Connecto class (according to the documentation the getConnection(user,password) method is not supported)
    I have a parallel installation of netbeans 3.5.1 (tomcat 4.0.6) with the same parameters (username, password, url...) and is still perfectly working
    Any help will be greatly appreciated,
    Andrea

    OK, I found the problem !
    It is not due to any configuration issue, but it is due to a BUG in tomcat 5.xx
    I reproduced the problem with mysql db server other than db2 db servver.
    The problem is the presence of the $ sign in the users' s password !!!!
    Probably the xml parser rading server.xml introduce some error finding $ sign.
    The problem is still present in the 5.028 version of tomcat.
    If i modify user's password REMOVING $ sign, everything is OK
    Perhaps $ sign should be escaped (?!?)
    Andrea

  • How to configure connection pooling in tomcat?

    how to configure connection pooling in tomcat and how to use the connection pooling in the jsp and servlets?

    thanks for the reply, i have configured the connection pool settings in the tomcat.
    I created a class with static method, which will return the connection object.
    whenever i need the connection object, iam invoking the static method, once its usage is over iam closing thew connection..
    is it the right way of using the connection object in the web application.

  • Connection Pooling in Tomcat with SQL Server

    Hey Guys,
    I have been banging my head against this all day :( so i now turn to you for some help :) I have a web app that uses a database now i want to start using this connection pooling that is supposed to be greatly more efficient than creating a new statement each time i need something from the database.
    I have read many articles about this already today and feel that a lot of the contradict each other and one thing that i saw was that there seems to be different way of doing this.
    One solution i have tried to implement but have so far failed is as follows:
    In Web app:
    Update Web.xml to include:
    <resource-ref>
            <description>
                Resource reference to a factory for java.sql.Connection
                instances that may be used for talking to a particular
                database that is configured in the server.xml file.
            </description>
            <res-ref-name>
                    jdbc/BBL
            </res-ref-name>
            <res-type>
                javax.sql.DataSource
            </res-type>
            <res-auth>
                Container
            </res-auth>
        </resource-ref>Update Context.xml to include:
    <Context path="/TEST_CON_POOLING">
    <Resource name="jdbc/BBL"
    auth="Container"
    type="javax.sql.DataSource"
    username="sa"
    password="sa"
    driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
    url="jdbc:microsoft:sqlserver://10.20.1.91:1433;DatabaseName=BBL"
    maxActive="8"
    maxIdle="4" />
    </Context>And then my jsp to test this:
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    --%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>JSP Page</title>
        </head>
        <body>
            <%@ page import="java.sql.ResultSet, java.sql.*,java.sql.SQLException,javax.naming.Context,javax.naming.InitialContext,
            javax.naming.NamingException,javax.sql.DataSource" %>
            <%
            Context initCtx = new InitialContext();
            Context envCtx = (Context) initCtx.lookup("java:comp/env");
            DataSource ds = (DataSource)
            envCtx.lookup("jdbc/BBL");
            Connection conn = ds.getConnection();
            //... use this connection to access the database ...
            Statement stmt = conn.createStatement();
            ResultSet rs = stmt.executeQuery("select id from users");
            while(rs.next()){
                out.write(rs.getString("ID"));
            conn.close();
            %>
        </body>
    </html>When i actually deply this i get the following nasty tomcat error:
    root cause
    org.apache.tomcat.dbcp.dbcp.SQLNestedException:
    Cannot create JDBC driver of class 'com.microsoft.sqlserver.jdbc.SQLServerDriver' for connect URL 'jdbc:microsoft:sqlserver://10.20.1.91:1433;DatabaseName=BBL'
         org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1150)
         org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
         org.apache.jsp.index_jsp._jspService(index_jsp.java:71)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    root cause
    java.sql.SQLException: No suitable driver
         java.sql.DriverManager.getDriver(DriverManager.java:243)
         org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1143)
         org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
         org.apache.jsp.index_jsp._jspService(index_jsp.java:71)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)As far as i know all the necessary sql server jar files are in my classpath, and any way i have them all sitting in the CATALINA_HOME/common/lib directory.
    Question:
    Am i going about this correctly? Some tutorials i have read say that i should be updateing the server.xml file but whenever i go near that tomcat will not even start.
    Help greatly appreciated.
    If there is anything i have not posted let me know and i will get it up.
    Rob

    Updating the server.xml file used to be necessary. It is no longer required, and actually not recommended any more.
    The best approach I feel is as you have done here, putting the definition into a context.xml file specifically for this application.
    In fact it all looks pretty good to me.
    JDBC driver jar in [TOMCAT]/common/lib - check
    Configuration in context.xml rather than server.xml - check
    Using JNDI - check.
    Have you got the connection url right?
    Is it jdbc:microsoft:sqlserver or just jdbc:sqlserver ? I have seen both on various sites around the internet.
    What version of SQL Server are you using? Check its documentation on the JDBC driver as to what class to use, and what the connection string should be.
    Try it in a plain java class - can you get a connection just using plain JDBC code?
    What values do you use for that?
    Hope this helps,
    evnafets

  • MySql connection pooling in Tomcat 4.1

    Hi,
    Could somebody help me before I go insane ?
    I have installed Tomcat 4.1 and MySql and is now trying to follow the example at http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.html to set up a pooled connection to the database.
    When i try to look up the DataSource :
    DataSource ds = (DataSource) initCtx.lookup("java:comp/env/jdbc/lonDB");
    I get an error :
    DbcpDataSourceFactory: driverClassName is required
    cheers
    /H

    Hello,
    Even though my problem is different, I just appended to this older posting because I am following the same tutorial for setting up a DB Conn pool with MySql.
    The problem that I am having is that Tomcat can't find the DBTest class which I copied and compiled from the tutorial.
    Where does one have to place their classes for Tomcat 4.1 to see them? In the older version of Tomcat which we use, all we had to was to place the class directory in the CLASSPATH variable on the server, and Tomcat was able to access the classes. We did the same approach for v4.1 but it does not seem to be working.
    Any help is appreciated!
    Thanks,
    Chris

  • How do i get connection pooling in tomcat

    hi 2 all,
    i m confused how to get connection with tomcat .
    thanx

    As Jerry says:
    Click on (only) 2 floating objects at a time. It sounds like you have more than 2 selected, otherwise you would not even see thee the menu option.
    Peter

  • Connection pooling error (Tomcat 5.5 Oracle 9i)

    Can someone please help,
    For the last 3 hours been search all past thread but no luck with my issue.
    I get error on line 4:
    == mytest.jsp
    Context initContext = new InitialContext();
    Context envContext = (Context)initContext.lookup("java:comp/env");
    OracleDataSource ds = (OracleDataSource)envContext.lookup("jdbc/nidev");
    ds.getConnection();
    ==
    Error:
    root cause
    javax.servlet.ServletException: invalid arguments in call
         org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:858)
         org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
         org.apache.jsp.common.configurations_jsp._jspService(configurations_jsp.java:101)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
    root cause
    java.sql.SQLException: invalid arguments in call
         oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)
         oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:162)
         oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:227)
         oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:200)
         oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:347)
    My Context:
    <Context reloadable="true"
    path="/dbbuild/nidev"
    debug="1"
    docBase="/home/nazrul/nidev/webapps/jsp">
    <Resource name="jdbc/nidev"
    auth="Container"
    type="oracle.jdbc.pool.OracleDataSource"
    driverClassName="oracle.jdbc.OracleDriver"
    factory="oracle.jdbc.pool.OracleDataSourceFactory"
    url="jdbc:oracle:thin:@192.168.10.2:1521:NIDEV"
    username="nislam"
    password="nislam"
    removeAbandoned="true"
    removeAbandonedTimeout="30"
    maxActive="50"
    maxIdle="3"
    maxWait="10000" />
    </Context>

    Any idea anyone?

  • Problem in DBCP Connection Pooling with BLOB in Tomcat

    Hi All,
    I am using the DBCP connection pooling in tomcat server version 6.0.18.
    I have session table which maintains the session details of the user in BLOB column. Recently I am facing a problem. When a user logs in, I am storing the session details in the DB. It throws an exception like this. When I restart the tomcat, it just works fine. But after some days it is again throwing the same exception.
    Code:
    2009-01-27 06:03:13,789 DEBUG [org.springframework.jdbc.core.JdbcTemplate] - Executing prepared SQL statement [INSERT INTO SESSION (SESSION_CODE,LAST_ACCESS,VALID_SESSION,SESSION_DATA) VALUES(?,?,?,?)]
    2009-01-27 06:03:13,789 DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager] - Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@154136a] for key [org.apache.commons.dbcp.BasicDataSource@bdec44] bound to thread [http-8443-6]
    2009-01-27 06:03:13,789 DEBUG [org.springframework.jdbc.core.StatementCreatorUtils] - Setting SQL statement parameter value: column index 1, parameter value [c2896a488efb7fe15430fab10d502577], value class [java.lang.String], SQL type unknown
    2009-01-27 06:03:13,789 DEBUG [org.springframework.jdbc.core.StatementCreatorUtils] - Setting SQL statement parameter value: column index 2, parameter value [1233064993], value class [java.lang.Long], SQL type unknown
    2009-01-27 06:03:13,789 DEBUG [org.springframework.jdbc.core.StatementCreatorUtils] - Setting SQL statement parameter value: column index 3, parameter value [1], value class [java.lang.Integer], SQL type unknown
    2009-01-27 06:03:13,789 DEBUG [org.springframework.jdbc.core.StatementCreatorUtils] - Setting SQL statement parameter value: column index 4, parameter value [org.springframework.jdbc.core.support.SqlLobValue@18af32e], value class [org.springframework.jdbc.core.support.SqlLobValue], SQL type 2004
    2009-01-27 06:03:13,789 DEBUG [org.springframework.jdbc.support.lob.DefaultLobHandler] - Set bytes for BLOB with length 390
    2009-01-27 06:03:13,789 DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager] - Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@154136a] for key [org.apache.commons.dbcp.BasicDataSource@bdec44] bound to thread [http-8443-6]
    2009-01-27 06:03:13,790 DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager] - Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@154136a] for key [org.apache.commons.dbcp.BasicDataSource@bdec44] bound to thread [http-8443-6]
    2009-01-27 06:03:13,790 DEBUG [org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator] - Unable to translate SQLException with Error code '17410', will now try the fallback translator
    2009-01-27 06:03:13,790 INFO [web.controller.LoginController] - Caught Exception while creating sesion in DB
    2009-01-27 06:03:13,790 DEBUG [org.springframework.jdbc.datasource.DataSourceTransactionManager] - Triggering beforeCompletion synchronization
    2009-01-27 06:03:13,790 DEBUG [org.springframework.jdbc.datasource.DataSourceTransactionManager] - Initiating transaction rollback
    2009-01-27 06:03:13,790 DEBUG [org.springframework.jdbc.datasource.DataSourceTransactionManager] - Rolling back JDBC transaction on Connection [jdbc:oracle:thin:@stagedb1c:2115:WEB1C, UserName=WEBAPP, Oracle JDBC driver]
    2009-01-27 06:03:13,791 DEBUG [org.springframework.jdbc.datasource.DataSourceTransactionManager] - Triggering afterCompletion synchronization
    2009-01-27 06:03:13,791 DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager] - Clearing transaction synchronization
    2009-01-27 06:03:13,791 DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager] - Removed value [org.springframework.jdbc.datasource.ConnectionHolder@154136a] for key [org.apache.commons.dbcp.BasicDataSource@bdec44] from thread [http-8443-6]
    2009-01-27 06:03:13,791 DEBUG [org.springframework.jdbc.datasource.DataSourceTransactionManager] - Releasing JDBC Connection [connection is closed] after transaction
    2009-01-27 06:03:13,791 DEBUG [org.springframework.jdbc.datasource.DataSourceUtils] - Returning JDBC Connection to DataSource
    2009-01-27 06:03:13,791 DEBUG [org.springframework.jdbc.datasource.DataSourceUtils] - Could not close JDBC Connection
    java.sql.SQLException: Already closed.
    at org.apache.commons.dbcp.PoolableConnection.close(PoolableConnection.java:84)
    at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.close(PoolingDataSource.java:181)
    at org.springframework.jdbc.datasource.DataSourceUtils.doReleaseConnection(DataSourceUtils.java:313)
    at org.springframework.jdbc.datasource.DataSourceUtils.releaseConnection(DataSourceUtils.java:274)
    at org.springframework.jdbc.datasource.DataSourceTransactionManager.doCleanupAfterCompletion(DataSourceTransactionManager.java:316)
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.cleanupAfterCompletion(AbstractPlatformTransactionManager.java:966)
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.processRollback(AbstractPlatformTransactionManager.java:832)
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.rollback(AbstractPlatformTransactionManager.java:777)
    at web.controller.LoginController.onSubmit(LoginController.java:109)
    at org.springframework.web.servlet.mvc.SimpleFormController.processFormSubmission(SimpleFormController.java:267)
    at org.springframework.web.servlet.mvc.AbstractFormController.handleRequestInternal(AbstractFormController.java:265)
    at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
    at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
    at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:511)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    at java.lang.Thread.run(Thread.java:595)
    My Session table has the following structure:
    Code:
    Name Null? Type
    SESSION_CODE NOT NULL VARCHAR2(100)
    LAST_ACCESS NOT NULL NUMBER
    VALID_SESSION NOT NULL NUMBER
    SESSION_DATA NOT NULL BLOB
    I have the following in the Spring context file :
    Code:
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName" value="${jdbc.driverClassName}"/>
    <property name="url" value="${jdbc.url}"/>
    <property name="username" value="${jdbc.username}"/>
    <property name="password" value="${jdbc.password}"/>
    <property name="initialSize" value="5"/>
    <property name="maxActive" value="5"/>
    <property name="minIdle" value="2"/>
    <property name="poolPreparedStatements" value="true"/>
    <property name="defaultAutoCommit" value="false"/>
    </bean>
    I am using the oracle.jdbc.driver.OracleDriver as jdbc driver. And also using the commons-dbcp-1.2.2.jar and ojdbc14.jar.
    Can some one help me out to solve this issue?
    Thanks in Advance.

    I am also facing the same problem, please let me know if there any suggestions,
    DEBUG|2010-05-07 16:41:25,866|main|(SQLErrorCodeSQLExceptionTranslator.java:266)|org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator|Unable to translate SQLException with Error code '17410', will now try the fallback translator
    DEBUG|2010-05-07 16:41:25,866|main|(SQLStateSQLExceptionTranslator.java:94)|org.springframework.jdbc.support.SQLStateSQLExceptionTranslator|Extracted SQL state class '08' from value '08000'
    thanks
    sundaravel n

  • MySQL connection pooling (tomcat) problem

    Hi all i just started learning servlets and i want to make a program in order to understand database connection pooling in tomcat.My problem is that when i run the servlet i created i get this error :
    java.lang.NullPointerException org.DB.TestDB2.doGet(TestDB2.java:105) javax.servlet.http.HttpServlet.service(HttpServlet.java:690) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
    And that from tomcat log from netbeans :
    org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null' 
    .I configured tomcat server.xml file like this :
    <Context path="/DBTest" docBase="DBTest"         debug="5" reloadable="true" crossContext="true">   <Resource name="jdbc/phonebook_db" auth="Container" type="javax.sql.DataSource"               maxActive="100" maxIdle="30" maxWait="10000"               username="*******" password="********" removeAbandoned="true"               removeAbandonedTimeout="120" driverClassName="com.mysql.jdbc.Driver"               url="jdbc:mysql://localhost:3306/test_phonebook_db?autoReconnect=true"/> </Context>   
    This is the resource reference i have in my web app web.xml file :
    <resource-ref>       <description>DB Connection</description>       <res-ref-name>jdbc/phonebook_db</res-ref-name>       <res-type>javax.sql.DataSource</res-type>       <res-auth>Container</res-auth>   </resource-ref> 
    And this is my servlet class :
    package org.DB;  import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import java.sql.*; import javax.naming.*; import javax.sql.*; public class TestDB2 extends HttpServlet { private Connection conn ; private Statement stat ; private ResultSet rs ; private int counter; private Object rsValue; public void init() {     try {             InitialContext ctx = new InitialContext();             DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/phonebook_db");             conn = ds.getConnection();             }         catch(Exception e) {               e.printStackTrace();         }     }     public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {         try {           stat = conn.createStatement();           rs = stat.executeQuery("SELECT * FROM phones_table");            } catch (SQLException sqle) {         sqle.printStackTrace();         }      response.setContentType("text/html; charset=utf-8");     PrintWriter out = response.getWriter();         String docType = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 " + "Transitional//EN\">\n";     out.println(docType +"<HTML>\n" + "<HEAD><TITLE>PhoneBook entries</TITLE></HEAD>\n");         counter = 0;     try {         while (rs.next()) {             out.println("<h4>Entry no. " + (++counter) + "</h4>");             out.println("<table width=\"75%\" border=\"1\">");             out.println("<tr>\n"+ "<td width=\21%\"><b>LastName:</b></td>\n"+ "<td width=\"79%\">");             out.println((((rsValue = rs.getObject("LASTNAME"))==null || rs.wasNull())?                 "":(rsValue.toString())));             out.println("</td>\n</tr>\n" +  "<tr>\n"+                     "<td width=\21%\"><b>FirstName:</b></td>\n"+ "<td width=\"79%\">");             out.println((((rsValue = rs.getObject("FIRSTNAME"))==null || rs.wasNull())?                 "":(rsValue.toString())));             out.println("</td>\n"+ "</tr>\n"+                     "<td width=\21%\"><b>Phone:</b></td>\n"+ "<td width=\"79%\">");             out.println((((rsValue = rs.getObject("PHONE"))==null || rs.wasNull())?                 "":(rsValue.toString())));             out.println("</td>\n" + "</tr>\n" +                     "</table>\n"+ "<br>\n<br>");         }     } catch (SQLException sqle) {         sqle.printStackTrace();     }     out.println("</body>\n"+             "</html>"); } public void destroy() {     try {         rs.close();         stat.close();         conn.close();     } catch (SQLException sqle) {         sqle.printStackTrace();         }     } }{code} Any suggestions?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    Thank you for your answer.Yes my servlet class is something more worse than horrible(i don't use the database connection correct i don't use the MVC pattern i use out.println() ) but i just tried to take a ready example and try to understand .So i write this servlet myself as a starting point :
    package org.DB;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import java.io.*;
    import java.sql.*;
    public class DBServlet extends HttpServlet {
        private Connection conn ;
        private Statement stat ;
        private ResultSet rs ;
        private int counter;
        String driver = "com.mysql.jdbc.Driver";
        String dbURL = "jdbc:mysql://localhost:3306/phonebookdb?user=**********&password=************";
        @Override
    public void init() {
         try {
                Class.forName(driver).newInstance();
                conn = DriverManager.getConnection(dbURL);
         }catch(Exception e) {
                  e.printStackTrace();
                  System.err.print("Unable to make connection ");
        protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
            response.setContentType("text/html;charset=UTF-8");
            PrintWriter out = response.getWriter();
            try {
                out.println("<html>");
                out.println("<head>");
                out.println("<title>Servlet DBServlet</title>"); 
                out.println("</head>");
                out.println("<body>");
                out.println("<h1>Servlet DBServlet at " + request.getContextPath () + "</h1>");
                out.println("<br /><br /><br />");
                if(conn!=null) 
                    out.println("conn object : "+conn);
                out.println("</body>");
                out.println("</html>");
            } catch(Exception sq) {
                System.out.println("Exception" + sq.getMessage());
                out.close();
        @Override
        protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
            processRequest(request, response);
        @Override
        protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
            processRequest(request, response);
         public void destroy() {
         try {
             conn.close();
         } catch (SQLException sqle) {
             sqle.printStackTrace();
        @Override
        public String getServletInfo() {
            return "A Simple Servlet";
    }And it work for now.
    Edited by: pavlos555 on Oct 21, 2008 10:21 AM

  • Tomcat 5.5 + JDBC connection pooling -- help

    I recently upgraded from java 1.4/tomcat 5.0 to java 1.5/tomcat 5.5. I am having difficulty getting connection pooling to work, however.
    Here are the details:
    1. Using mysql 4.1.3 beta -- it has been working fine for my purposes for a while
    2. put mysql-connector-java-3.1.7-bin.jar in tomcat/common/lib.
    3. Here is server.xml:
    <Server port="8005" shutdown="SHUTDOWN">
        <GlobalNamingResources>
            <Resource auth="Container" name="jdbc/TestDB"
            type="javax.sql.DataSource"/>
            <ResourceParams name="jdbc/TestDB">
                <parameter>
                    <name>url</name>
                    <value>jdbc:mysql://localhost:3306/TestDB?autoReconnect=true</value>
                </parameter>
                <parameter>
                    <name>maxIdle</name>
                    <value>40</value>
                </parameter>
                <parameter>
                    <name>maxActive</name>
                    <value>150</value>
                </parameter>
                <parameter>
                    <name>driverClassName</name>
                    <value>com.mysql.jdbc.Driver</value>
                </parameter>
                <parameter>
                    <name>maxWait</name>
                    <value>3000</value>
                </parameter>
                <parameter>
                    <name>removeAbandoned</name>
                    <value>true</value>
                </parameter>
                <parameter>
                    <name>username</name>
                    <value>webapp</value>
                </parameter>
                <parameter>
                    <name>factory</name>
                    <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
                </parameter>
                <parameter>
                    <name>logAbandoned</name>
                    <value>true</value>
                </parameter>
                <parameter>
                    <name>removeAbandonedTimeout</name>
                    <value>90</value>
                </parameter>
                <parameter>
                    <name>password</name>
                    <value>secret</value>
                </parameter>
            </ResourceParams>
        </GlobalNamingResources>
        <Service name="Catalina">
            <Connector port="8080" />
            <Engine name="Catalina" defaultHost="localhost">
                <Host appBase="webapps"
                      autoDeploy="true"
                      debug="5"
                      liveDeploy="true"
                      name="localhost"
                      unpackWARs="true"
                      xmlValidation="true"/>
            </Engine>
        </Service>
    </Server>4. My application is called "bertle". Here is tomcat/conf/Catalina/localhost/bertle.xml:
    <Context path="/bertle" reloadable="true"
             docBase="C:\eclipse\workspace\bertle\bertle"
             workDir="C:\eclipse\workspace\bertle\work">
        <ResourceLink global="jdbc/TestDB"
                      name="jdbc/TestDB"
                      type="javax.sql.DataSource" />
    </Context>5. Tomcat starts up find without showing any errors. However, when I try and run the application I get an error. The error occurs when the user tries to log in, which involves querying the mysql database. Here is some of what it spits up:
    SEVERE: Error in validating user.
    Feb 28, 2005 5:05:16 PM edu.harvard.dsg.chv.model.LoginBean validateUser
    SEVERE: SQL statement =
    org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'
         at  org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:780)
         at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)
         at mypackage.model.LoginBean.validateUser(LoginBean.java:49)
         at mypackage.action.LoginAction.execute(LoginAction.java:58)6. Here is the line at LoginBean.java:49:
    49    con = dataSource.getConnection();Here are the lines at LoginAction.java:58
    46        // Obtain our environment naming context
    47        Context initCtx = new InitialContext();
    48        Context envCtx = (Context) initCtx.lookup("java:comp/env");
    49       
    50        // Look up our data source
    51        DataSource ds = (DataSource) envCtx.lookup("jdbc/TestDB");
    52       
    53        // create a new LoginBean passing the datasource
    54        LoginBean lb = new LoginBean(ds);
    55       
    56        // check to see if this user/password combination are valid
    57        // will return a non-null UserDTO if valid
    58        UserDTO user = lb.validateUser((String)((DynaValidatorForm)form).get("handle"),
    59                (String)((DynaValidatorForm)form).get("password"));Is there something I am also supposed to add to WEB-INF/web.xml ?
    I am offering many kudos to anyone who can tell me what I am overlooking.
    Thanks,
    Jon

    the stuff you added in server.xml is old and wiilnot
    work with 5.5.*
    might pass dtd but it will not work
    did you try changing it to new layoutI gave you one Duke dollar for helping me with this.
    I will give another one to anyone who can tell me
    e how to set up global connection pooling in tomcat.Hi,
    Please bear with me for replying to a thread that's a week old.
    I was trying to set up connection pooling in tomcat and this thread helped me clear up some issues for the same.
    Incidentally google returns this thread among the top 10 when i search for tomcat 5.5 connection pooling.
    There are some unexplained questions here (regarding global connection pooling) and since I was able to set that up too, this may, in the future, benefit anybody who faces similar issues.
    Setting Up Global Connection Pooling
    Add this piece of code to server.xml under the server element
    <Server port="8005" shutdown="SHUTDOWN">
      <!-- other elements -->
      <GlobalNamingResources>
         <!-- other global resources-->
          <Resource name="jdbc/learning" auth="Container"                      type="javax.sql.DataSource" driverClassName="oracle.jdbc.driver.OracleDriver"
                         url="jdbc:oracle:thin:@localhost:1521:learning"
                         username="Learning" password="Learning" maxActive="20" maxIdle="10"  maxWait="-1"/>         
      </GlobalNamingResources>And then in your context file (which may be the <webapps>/<your appn>/META-INF/<your_web_app.xml> directory or conf/catalina/localhost/<your_web_app.xml>)
    add this code
    <Context docBase="${catalina.home}/webapps/webtest"
             privileged="true" antiResourceLocking="false" antiJARLocking="false">
    <!-- Use this if you dont require global resources
      <Resource name="jdbc/learning" auth="Container"
                         type="javax.sql.DataSource" driverClassName="oracle.jdbc.driver.OracleDriver"
                         url="jdbc:oracle:thin:@localhost:1521:learning"
                         username="Learning" password="Learning" maxActive="20" maxIdle="10"
                  maxWait="-1"/>
    -->
    <!-- this is a resource link if you have defined resource globally-->
    <ResourceLink
                name="jdbc/learning"
                global="jdbc/learning"
                type="javax.sql.DataSource"
              />
    </Context>also tomcat recommends defining the docBase outside the webapps directory (ie any other location outside the tomcat installation dir) if you choose to define contexts in xml files.
    thanks,
    ram.

  • Tomcat 5.5 Connection Pooling problem

    Hi,
    I am trying to setup JDBC connection pooling in Tomcat 5.5 using DB2 database and IBM RAD 7.0 IDE. Although The setup described in JNDI Resources HOW-TO(http://tomcat.apache.org/tomcat-5.5-doc/jndi-resources-howto.html) for creating JDBC Datasources did work, I would like to work with real connection pooling, which means not declaring datasources into the /META-INF/context.xml file of each web app but having them as <GlobalNamingResources> into /conf/server.xml and accessing them through <ResourceLink> references from /conf/context.xml (or /conf/catalina/localhost/ROOT.xml). However I am stuck with Exception javax.naming.NameNotFoundException: Name jdbc is not bound in this Context. Even if I add an: <resource-env-ref>
              <description>
              </description>
              <resource-env-ref-name>jdbc/DB2T</resource-env-ref-name>
              <resource-env-ref-type>javax.sql.DataSource</resource-env-ref-type>
         </resource-env-ref> record in my /WEB-INF/web.xml I get a javax.naming.NamingException: Cannot create resource instance Exception.
    Does anyone have an idea how to resolve this?
    Here are my configurations:
    -----------------/conf/server.xml-------------------
    <Server port="8005" shutdown="SHUTDOWN">
      <!-- Global JNDI resources -->
      <GlobalNamingResources>
       <Resource name="jdbc/DB2T" auth="Container"
       type="javax.sql.DataSource" removeAbandoned="true"
      factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
       removeAbandonedTimeout="30" maxActive="100"
       maxIdle="30" maxWait="10000" username="id"
       password="pass"
       driverClassName="com.ibm.db2.jcc.DB2Driver"
       url="jdbc:db2://<ip-addrr>:<port>/dbname"/>
      </GlobalNamingResources>------------------/conf/context.xml----------------------
    <!-- The contents of this file will be loaded for each web application -->
    <Context>
        <!-- Default set of monitored resources -->
        <WatchedResource>WEB-INF/web.xml</WatchedResource>
        <WatchedResource>META-INF/context.xml</WatchedResource>
    <ResourceLink name="jdbc/DB2T" global="jdbc/DB2T"  type="javax.sql.DataSource"/>
    </Context>I also try to get the resource with java code like this:
    DataSource ds;
    InitialContext DSCtx = new InitialContext();
    ds = (DataSource) DSCtx.lookup("java:/comp/env/jdbc/DB2T"); PS: When I start the tomcat and hit http://localhost:8080 I can't get the default page although every web app I run loads without problems. Do you think this has a relation with the above problem?

    hi,
    I think your datasource configuration is incorrect
    see this http://tomcat.apache.org/tomcat-5.0-doc/config/globalresources.html
    and this
    http://forum.java.sun.com/thread.jspa?threadID=610046&messageID=3348979
    <GlobalNamingResources ...>
      <ResourceParams name="jdbc/EmployeeDB">
        <parameter>
          <name>driverClassName</name>
          <value>org.hsql.jdbcDriver</value>
        </parameter>
        <parameter>
          <name>driverName</name>
          </value>jdbc:HypersonicSQL:database</value>
        </parameter>
        <parameter>
          <name>user</name>
          <value>dbusername</value>
        </parameter>
        <parameter>
          <name>password</name>
          <value>dbpassword</value>
        </parameter>
      </ResourceParams>
    </GlobalNamingResources>be sure that your jdbc driver library (.jar), commons-pool-xx.jar and commons-dbcp-xx.jar are under TOMCAT_DIR/common/lib/
    hope that helps

Maybe you are looking for

  • Why 3 queries are generated while running a report?

    Hi All, I'm into SA production support team. Currently i'm curious to know that why 3 queries are getting generated in Siebel Analytics server log while i'm running a pivot report in Answer? Can anyone explain it? Is there any issue with the RPD itse

  • Cannot print crop marks in Adobe Reader 9.4.2, 10.1

    Printing from an A4 pdf to A3. Using a full version of Adobe 7 or 9.42. the crop marks appear but using Adobe Reader 9.4.2 and up no crop marks appear. Show art, trim, & bleed boxes is ticked. Does Adobe Reader print these marks? Thanks in advance.

  • Passbook show in lock screen option missing on starbucks

    Is it just me, but when I re-added the starbucks passbook option back in to passbooks, my option for show in lock screen is missng. I removed the starbucks option from passbook as it never worked for me using passbook. Any idea on how to add the show

  • Transformation in SQL Loader

    Hi all, I am in the process of loading the data using sql loader. I need to transform the data when I load I have a data in flat file as below 1     10,20,30,40     vijay 2     10,20     jagdeeshI need to load this data as 1     10     vijay 1     20

  • BAPI to find number of users  in HR module

    Hi , I wanted to know if there exist BAPI that would return me the number of SAP HR module users in a system. I cam across the BAPI's for info types like personu2019s Personal Data (Infotype 0002) BAPI_PERSDATA_CHANGE u2013 Change personal data BAPI_