You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by William Nguyen <wn...@yahoo.com> on 2003/12/03 03:08:36 UTC

Tomcat 5.x - Cannot create PoolableConnectionFactory

I'm having the most difficult time trying to get my
web app to connect to a database (MS Access via
sun.jdbc.odbc.JdbcOdbcDriver).  I've registered an
odbc datasource in Windows and have gotten the
application to work in a command prompt.  I've tried
my best to emulate the examples provided in 8. JNDI
Resources HOW-TO and 9. JDBC Datasources as well as
searches all over the net.  I've extracted the
JdbcOdbcDriver class file from rt.jar and placed it in
a dbconn.jar file in [$CATALINA_HOME]/common/lib (I've
also tried just putting rt.jar in there).  The error
message I get states, "Cannot create
PoolableConnectionFactory."

server.xml
<Host appBase="webapps" name="localhost">
 <Logger
className="org.apache.catalina.logger.FileLogger"
prefix="localhost_log." suffix=".txt"
timestamp="true"/>
  <Context path="/TimeTrack" docBase="TimeTrack">
    <Resource name="jdbc/TimeTrack" auth="Container"
type="javax.sql.DataSource"/>
    <ResourceParams name="jdbc/TimeTrack">
      <parameter>
        <name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
      </parameter>
      <parameter>
        <name>maxWait</name>
        <value>5000</value>
      </parameter>
      <parameter>
        <name>maxActive</name>
        <value>4</value>
      </parameter>
      <parameter>
        <name>password</name>
        <value>password</value>
      </parameter>
      <parameter>
        <name>url</name>
        <value>jdbc:odbc:TimeTrack</value>
      </parameter>
      <parameter>
        <name>driverClassName</name>
        <value>sun.jdbc.odbc.JdbcOdbcDriver</value>
      </parameter>
      <parameter>
        <name>maxIdle</name>
        <value>2</value>
      </parameter>
      <parameter>
        <name>username</name>
        <value>admin</value>
      </parameter>
    </ResourceParams>  
  </Context>
</Host>


web.xml
<resource-ref>
  <description>datasource</description>
  <res-ref-name>jdbc/TimeTrack</res-ref-name>
  <res-type>javax.sql.DataSource</res-type>
  <res-auth>Container</res-auth>
</resource-ref>

Source code: A servlet calls a class that calls this
class.
try
{
 ErrorLog.writeErrorLog("0");
 Context initCtx = new InitialContext();
 ErrorLog.writeErrorLog("1");
 Context envCtx = (Context)
initCtx.lookup("java:comp/env");
 ErrorLog.writeErrorLog("2");
 DataSource ds =
(DataSource)envCtx.lookup("jdbc/TimeTrack");
 ErrorLog.writeErrorLog(ds.toString());
 ErrorLog.writeErrorLog("3");
 conn = ds.getConnection();
 ErrorLog.writeErrorLog("4");
 stmt =
conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
 ErrorLog.writeErrorLog("5");
 //if all successful, return true
 return true;
}
catch (NamingException ne)
{
 ErrorLog.writeErrorLog("Naming exception open");
 ErrorLog.writeErrorLog(ne.getMessage());
 ErrorLog.writeErrorLog("Naming excepton close");
 return false;
}
catch (SQLException sqle)
{
 ErrorLog.writeErrorLog("SQLEXception open");
 ErrorLog.writeErrorLog(sqle.getMessage());
 ErrorLog.writeErrorLog("SQLEXception close");
 return false;
}

And the output to the error log
12/2/2003 4:19:57 PM: 0
12/2/2003 4:19:57 PM: 1
12/2/2003 4:19:57 PM: 2
12/2/2003 4:19:57 PM:
org.apache.commons.dbcp.BasicDataSource@e22f2b
12/2/2003 4:19:57 PM: 3
12/2/2003 4:19:57 PM: SQLEXception open
12/2/2003 4:19:57 PM: Cannot create
PoolableConnectionFactory
12/2/2003 4:19:57 PM: SQLEXception close
 
Any advice would get greatly appreciated.  Thanks.

__________________________________
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
http://companion.yahoo.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Tomcat 5.x - Cannot create PoolableConnectionFactory

Posted by William Nguyen <wn...@yahoo.com>.
Silly mistake.  I created a User DSN instead of a
System DSN.

Regards,
Will Nguyen

--- William Nguyen <wn...@yahoo.com> wrote:
> I'm having the most difficult time trying to get my
> web app to connect to a database (MS Access via
> sun.jdbc.odbc.JdbcOdbcDriver).  I've registered an
> odbc datasource in Windows and have gotten the
> application to work in a command prompt.  I've tried
> my best to emulate the examples provided in 8. JNDI
> Resources HOW-TO and 9. JDBC Datasources as well as
> searches all over the net.  I've extracted the
> JdbcOdbcDriver class file from rt.jar and placed it
> in
> a dbconn.jar file in [$CATALINA_HOME]/common/lib
> (I've
> also tried just putting rt.jar in there).  The error
> message I get states, "Cannot create
> PoolableConnectionFactory."
> 
> server.xml
> <Host appBase="webapps" name="localhost">
>  <Logger
> className="org.apache.catalina.logger.FileLogger"
> prefix="localhost_log." suffix=".txt"
> timestamp="true"/>
>   <Context path="/TimeTrack" docBase="TimeTrack">
>     <Resource name="jdbc/TimeTrack" auth="Container"
> type="javax.sql.DataSource"/>
>     <ResourceParams name="jdbc/TimeTrack">
>       <parameter>
>         <name>factory</name>
>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
>       </parameter>
>       <parameter>
>         <name>maxWait</name>
>         <value>5000</value>
>       </parameter>
>       <parameter>
>         <name>maxActive</name>
>         <value>4</value>
>       </parameter>
>       <parameter>
>         <name>password</name>
>         <value>password</value>
>       </parameter>
>       <parameter>
>         <name>url</name>
>         <value>jdbc:odbc:TimeTrack</value>
>       </parameter>
>       <parameter>
>         <name>driverClassName</name>
>         <value>sun.jdbc.odbc.JdbcOdbcDriver</value>
>       </parameter>
>       <parameter>
>         <name>maxIdle</name>
>         <value>2</value>
>       </parameter>
>       <parameter>
>         <name>username</name>
>         <value>admin</value>
>       </parameter>
>     </ResourceParams>  
>   </Context>
> </Host>
> 
> 
> web.xml
> <resource-ref>
>   <description>datasource</description>
>   <res-ref-name>jdbc/TimeTrack</res-ref-name>
>   <res-type>javax.sql.DataSource</res-type>
>   <res-auth>Container</res-auth>
> </resource-ref>
> 
> Source code: A servlet calls a class that calls this
> class.
> try
> {
>  ErrorLog.writeErrorLog("0");
>  Context initCtx = new InitialContext();
>  ErrorLog.writeErrorLog("1");
>  Context envCtx = (Context)
> initCtx.lookup("java:comp/env");
>  ErrorLog.writeErrorLog("2");
>  DataSource ds =
> (DataSource)envCtx.lookup("jdbc/TimeTrack");
>  ErrorLog.writeErrorLog(ds.toString());
>  ErrorLog.writeErrorLog("3");
>  conn = ds.getConnection();
>  ErrorLog.writeErrorLog("4");
>  stmt =
>
conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
> ResultSet.CONCUR_UPDATABLE);
>  ErrorLog.writeErrorLog("5");
>  //if all successful, return true
>  return true;
> }
> catch (NamingException ne)
> {
>  ErrorLog.writeErrorLog("Naming exception open");
>  ErrorLog.writeErrorLog(ne.getMessage());
>  ErrorLog.writeErrorLog("Naming excepton close");
>  return false;
> }
> catch (SQLException sqle)
> {
>  ErrorLog.writeErrorLog("SQLEXception open");
>  ErrorLog.writeErrorLog(sqle.getMessage());
>  ErrorLog.writeErrorLog("SQLEXception close");
>  return false;
> }
> 
> And the output to the error log
> 12/2/2003 4:19:57 PM: 0
> 12/2/2003 4:19:57 PM: 1
> 12/2/2003 4:19:57 PM: 2
> 12/2/2003 4:19:57 PM:
> org.apache.commons.dbcp.BasicDataSource@e22f2b
> 12/2/2003 4:19:57 PM: 3
> 12/2/2003 4:19:57 PM: SQLEXception open
> 12/2/2003 4:19:57 PM: Cannot create
> PoolableConnectionFactory
> 12/2/2003 4:19:57 PM: SQLEXception close
>  
> Any advice would get greatly appreciated.  Thanks.
> 
> __________________________________
> Do you Yahoo!?
> Free Pop-Up Blocker - Get it now
> http://companion.yahoo.com/
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> tomcat-user-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
http://companion.yahoo.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org