Re: DBCP ClassCastException

2005-05-11 Thread Nikola Milutinovic
Dhiren Bhatia wrote:
I'm using BasicDataSource because javax.sql.DataSource does not have methods 
to set the driver class name, url, username/pwd etc. My app needs to support 
different databases and the driver is loaded based on which database is 
installed.
 

You've got it backwards. It is the responsibility of a J2EE container to 
use whatever the implementatio it likes and set those parameters and 
then give your application just javax.sql.DataSource. THAT will make 
your application portable.

Nix.
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: DBCP ClassCastException

2005-05-09 Thread Lutz Zetzsche
Hi Dhiren,

Am Montag, 9. Mai 2005 07:36 schrieb Dhiren Bhatia:
 Hi all,

 I'm getting a the following ClassCastException running Tomcat 5.5.9
 with MySQL

 java.lang.ClassCastException:
 org.apache.tomcat.dbcp.dbcp.BasicDataSource

 Here's the relevant code:
  *Java code:*
 org.apache.commons.dbcp.BasicDataSource datasource;

 datasource =
 (BasicDataSource)ctx.lookup(java:comp/env/jdbc/myserver);

 *web.xml*
 resource-ref
 descriptionDB Connection/description
 res-ref-namejdbc/myserver/res-ref-name
 res-typejavax.sql.DataSource/res-type
 res-authContainer/res-auth
 /resource-ref
  *server.xml*
 **
  ResourceParams name=jdbc/myserver
 parameter
 namefactory/name
 valueorg.apache.commons.dbcp.BasicDataSourceFactory/value
 /parameter
 *...*


 This same code works in Tomcat 5.0.30.

 Has anything changed? Am I missing something?

Yes. The syntax for the Resource tag in the server.xml has changed. The 
resource parameters are no longer defined in tags nested into the 
Resource tag, but in attributes of the tag. This is an example from the 
Tomcat 5.5 documentation:

Resource   name=jdbc/TestDB auth=Container 
type=javax.sql.DataSource maxActive=100 maxIdle=30
maxWait=1 username=javauser password=javadude
driverClassName=com.mysql.jdbc.Driver

url=jdbc:mysql://localhost:3306/javatest?autoReconnect=true/

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


Best wishes,

Lutz

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: DBCP ClassCastException

2005-05-09 Thread Dhiren Bhatia
Hi Lutz,
 I changed the Resource tag definition to:
  Resource name=jdbc/myserver auth=Container type=javax.sql.DataSource

maxActive=100 maxIdle=30 maxWait=1
driverClassName=com.mysql.jdbc.Driver/
 I'm setting the username/password and jdbcurl using code.
 I still get the same ClassCastException. Is Tomcat instantiating the 
correct DataSourceFactory?
I have the commons-dbcp-1.2.1.jar in my ${TOMCAT_HOME}/common/lib
 Thanks,
 Dhiren

 On 5/8/05, Lutz Zetzsche [EMAIL PROTECTED] wrote: 
 
 Hi Dhiren,
 
 Am Montag, 9. Mai 2005 07:36 schrieb Dhiren Bhatia:
  Hi all,
 
  I'm getting a the following ClassCastException running Tomcat 5.5.9
  with MySQL
 
  java.lang.ClassCastException:
  org.apache.tomcat.dbcp.dbcp.BasicDataSource
 
  Here's the relevant code:
  *Java code:*
  org.apache.commons.dbcp.BasicDataSource datasource;
 
  datasource =
  (BasicDataSource)ctx.lookup(java:comp/env/jdbc/myserver);
 
  *web.xml*
  resource-ref
  descriptionDB Connection/description
  res-ref-namejdbc/myserver/res-ref-name
  res-typejavax.sql.DataSource/res-type
  res-authContainer/res-auth
  /resource-ref
  *server.xml*
  **
  ResourceParams name=jdbc/myserver
  parameter
  namefactory/name
  valueorg.apache.commons.dbcp.BasicDataSourceFactory/value
  /parameter
  *...*
 
 
  This same code works in Tomcat 5.0.30.
 
  Has anything changed? Am I missing something?
 
 Yes. The syntax for the Resource tag in the server.xml has changed. The
 resource parameters are no longer defined in tags nested into the
 Resource tag, but in attributes of the tag. This is an example from the
 Tomcat 5.5 documentation:
 
 Resource name=jdbc/TestDB auth=Container
 type=javax.sql.DataSource maxActive=100 maxIdle=30
 maxWait=1 username=javauser password=javadude
 driverClassName=com.mysql.jdbc.Driver
 url=jdbc:mysql://localhost:3306/javatest?autoReconnect=true/
 
 
 http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples-howto.html
 
 Best wishes,
 
 Lutz
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 



AW: DBCP ClassCastException

2005-05-09 Thread Pfingstl Gernot
Tomcat 5.5 doesn't use commons-dbcp directly, the tomcat team took the source 
and put it in other packages.
So you should use org.apache.tomcat.dbcp.dbcp.BasicDataSource instead of 
org.apache.commons.dbcp.BasicDataSource in your source - btw why do you cast to 
BasicDataSource, you can use javax.sql.DataSource?

Gernot

-Ursprüngliche Nachricht-
Von: Dhiren Bhatia [mailto:[EMAIL PROTECTED]
Gesendet: Montag, 09. Mai 2005 17:19
An: Tomcat Users List
Betreff: Re: DBCP ClassCastException


Hi Lutz,
 I changed the Resource tag definition to:
  Resource name=jdbc/myserver auth=Container type=javax.sql.DataSource

maxActive=100 maxIdle=30 maxWait=1
driverClassName=com.mysql.jdbc.Driver/
 I'm setting the username/password and jdbcurl using code.
 I still get the same ClassCastException. Is Tomcat instantiating the 
correct DataSourceFactory?
I have the commons-dbcp-1.2.1.jar in my ${TOMCAT_HOME}/common/lib
 Thanks,
 Dhiren

 On 5/8/05, Lutz Zetzsche [EMAIL PROTECTED] wrote: 
 
 Hi Dhiren,
 
 Am Montag, 9. Mai 2005 07:36 schrieb Dhiren Bhatia:
  Hi all,
 
  I'm getting a the following ClassCastException running Tomcat 5.5.9
  with MySQL
 
  java.lang.ClassCastException:
  org.apache.tomcat.dbcp.dbcp.BasicDataSource
 
  Here's the relevant code:
  *Java code:*
  org.apache.commons.dbcp.BasicDataSource datasource;
 
  datasource =
  (BasicDataSource)ctx.lookup(java:comp/env/jdbc/myserver);
 
  *web.xml*
  resource-ref
  descriptionDB Connection/description
  res-ref-namejdbc/myserver/res-ref-name
  res-typejavax.sql.DataSource/res-type
  res-authContainer/res-auth
  /resource-ref
  *server.xml*
  **
  ResourceParams name=jdbc/myserver
  parameter
  namefactory/name
  valueorg.apache.commons.dbcp.BasicDataSourceFactory/value
  /parameter
  *...*
 
 
  This same code works in Tomcat 5.0.30.
 
  Has anything changed? Am I missing something?
 
 Yes. The syntax for the Resource tag in the server.xml has changed. The
 resource parameters are no longer defined in tags nested into the
 Resource tag, but in attributes of the tag. This is an example from the
 Tomcat 5.5 documentation:
 
 Resource name=jdbc/TestDB auth=Container
 type=javax.sql.DataSource maxActive=100 maxIdle=30
 maxWait=1 username=javauser password=javadude
 driverClassName=com.mysql.jdbc.Driver
 url=jdbc:mysql://localhost:3306/javatest?autoReconnect=true/
 
 
 http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples-howto.html
 
 Best wishes,
 
 Lutz
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: DBCP ClassCastException

2005-05-09 Thread Dhiren Bhatia
I'm using BasicDataSource because javax.sql.DataSource does not have methods 
to set the driver class name, url, username/pwd etc. My app needs to support 
different databases and the driver is loaded based on which database is 
installed.
 If I use org.apache.tomcat.dbcp.dbcp.BasicDataSource, then my code is not 
portable to JBoss/Weblogic etc right? BTW, which jar is 
org.apache.tomcat.dbcp.dbcp.BasicDataSource in?
 Thanks for your response.
 Dhiren


 On 5/9/05, Pfingstl Gernot [EMAIL PROTECTED] wrote: 
 
 Tomcat 5.5 doesn't use commons-dbcp directly, the tomcat team took the 
 source and put it in other packages.
 So you should use org.apache.tomcat.dbcp.dbcp.BasicDataSource instead of 
 org.apache.commons.dbcp.BasicDataSource in your source - btw why do you 
 cast to BasicDataSource, you can use javax.sql.DataSource?
 
 Gernot
 
 -Ursprüngliche Nachricht-
 Von: Dhiren Bhatia [mailto:[EMAIL PROTECTED]
 Gesendet: Montag, 09. Mai 2005 17:19
 An: Tomcat Users List
 Betreff: Re: DBCP ClassCastException
 
 
 Hi Lutz,
 I changed the Resource tag definition to:
 Resource name=jdbc/myserver auth=Container type=javax.sql.DataSource
 
 maxActive=100 maxIdle=30 maxWait=1
 driverClassName=com.mysql.jdbc.Driver/
 I'm setting the username/password and jdbcurl using code.
 I still get the same ClassCastException. Is Tomcat instantiating the
 correct DataSourceFactory?
 I have the commons-dbcp-1.2.1.jar in my ${TOMCAT_HOME}/common/lib
 Thanks,
 Dhiren
 
 On 5/8/05, Lutz Zetzsche [EMAIL PROTECTED] wrote:
 
  Hi Dhiren,
 
  Am Montag, 9. Mai 2005 07:36 schrieb Dhiren Bhatia:
   Hi all,
  
   I'm getting a the following ClassCastException running Tomcat 5.5.9
   with MySQL
  
   java.lang.ClassCastException:
   org.apache.tomcat.dbcp.dbcp.BasicDataSource
  
   Here's the relevant code:
   *Java code:*
   org.apache.commons.dbcp.BasicDataSource datasource;
  
   datasource =
   (BasicDataSource)ctx.lookup(java:comp/env/jdbc/myserver);
  
   *web.xml*
   resource-ref
   descriptionDB Connection/description
   res-ref-namejdbc/myserver/res-ref-name
   res-typejavax.sql.DataSource/res-type
   res-authContainer/res-auth
   /resource-ref
   *server.xml*
   **
   ResourceParams name=jdbc/myserver
   parameter
   namefactory/name
   valueorg.apache.commons.dbcp.BasicDataSourceFactory/value
   /parameter
   *...*
  
  
   This same code works in Tomcat 5.0.30.
  
   Has anything changed? Am I missing something?
 
  Yes. The syntax for the Resource tag in the server.xml has changed. The
  resource parameters are no longer defined in tags nested into the
  Resource tag, but in attributes of the tag. This is an example from the
  Tomcat 5.5 documentation:
 
  Resource name=jdbc/TestDB auth=Container
  type=javax.sql.DataSource maxActive=100 maxIdle=30
  maxWait=1 username=javauser password=javadude
  driverClassName=com.mysql.jdbc.Driver
  url=jdbc:mysql://localhost:3306/javatest?autoReconnect=true/
 
 
  
 http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples-howto.html
 
  Best wishes,
 
  Lutz
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 



AW: DBCP ClassCastException

2005-05-09 Thread Pfingstl Gernot
You can find org.apache.tomcat.dbcp.dbcp.BasicDataSource in 
common/lib/naming-factory-dbcp.jar.
If you put commons-dbcp.jar, commons-pool.jar and commons-collections.jar in 
common/lib you (maybe) should be able to use 
org.apache.commons.dbcp.BasicDataSource. 
I do it in a similar way - I have my own ressource factory, which extends 
org.apache.commons.dbcp.BasicDataSourceFactory and it works in tomcat 5.5 with 
the above jars.

Gernot

-Ursprüngliche Nachricht-
Von: Dhiren Bhatia [mailto:[EMAIL PROTECTED]
Gesendet: Montag, 09. Mai 2005 18:47
An: Tomcat Users List
Betreff: Re: DBCP ClassCastException


I'm using BasicDataSource because javax.sql.DataSource does not have methods 
to set the driver class name, url, username/pwd etc. My app needs to support 
different databases and the driver is loaded based on which database is 
installed.
 If I use org.apache.tomcat.dbcp.dbcp.BasicDataSource, then my code is not
portable to JBoss/Weblogic etc right? BTW, which jar is 
org.apache.tomcat.dbcp.dbcp.BasicDataSource in?
 Thanks for your response.
 Dhiren


 On 5/9/05, Pfingstl Gernot [EMAIL PROTECTED] wrote: 
 
 Tomcat 5.5 doesn't use commons-dbcp directly, the tomcat team took the
 source and put it in other packages.
 So you should use org.apache.tomcat.dbcp.dbcp.BasicDataSource instead of
 org.apache.commons.dbcp.BasicDataSource in your source - btw why do you
 cast to BasicDataSource, you can use javax.sql.DataSource?
 
 Gernot
 
 -Ursprüngliche Nachricht-
 Von: Dhiren Bhatia [mailto:[EMAIL PROTECTED]
 Gesendet: Montag, 09. Mai 2005 17:19
 An: Tomcat Users List
 Betreff: Re: DBCP ClassCastException
 
 
 Hi Lutz,
 I changed the Resource tag definition to:
 Resource name=jdbc/myserver auth=Container type=javax.sql.DataSource
 
 maxActive=100 maxIdle=30 maxWait=1
 driverClassName=com.mysql.jdbc.Driver/
 I'm setting the username/password and jdbcurl using code.
 I still get the same ClassCastException. Is Tomcat instantiating the
 correct DataSourceFactory?
 I have the commons-dbcp-1.2.1.jar in my ${TOMCAT_HOME}/common/lib
 Thanks,
 Dhiren
 
 On 5/8/05, Lutz Zetzsche [EMAIL PROTECTED] wrote:
 
  Hi Dhiren,
 
  Am Montag, 9. Mai 2005 07:36 schrieb Dhiren Bhatia:
   Hi all,
  
   I'm getting a the following ClassCastException running Tomcat 5.5.9
   with MySQL
  
   java.lang.ClassCastException:
   org.apache.tomcat.dbcp.dbcp.BasicDataSource
  
   Here's the relevant code:
   *Java code:*
   org.apache.commons.dbcp.BasicDataSource datasource;
  
   datasource =
   (BasicDataSource)ctx.lookup(java:comp/env/jdbc/myserver);
  
   *web.xml*
   resource-ref
   descriptionDB Connection/description
   res-ref-namejdbc/myserver/res-ref-name
   res-typejavax.sql.DataSource/res-type
   res-authContainer/res-auth
   /resource-ref
   *server.xml*
   **
   ResourceParams name=jdbc/myserver
   parameter
   namefactory/name
   valueorg.apache.commons.dbcp.BasicDataSourceFactory/value
   /parameter
   *...*
  
  
   This same code works in Tomcat 5.0.30.
  
   Has anything changed? Am I missing something?
 
  Yes. The syntax for the Resource tag in the server.xml has changed. The
  resource parameters are no longer defined in tags nested into the
  Resource tag, but in attributes of the tag. This is an example from the
  Tomcat 5.5 documentation:
 
  Resource name=jdbc/TestDB auth=Container
  type=javax.sql.DataSource maxActive=100 maxIdle=30
  maxWait=1 username=javauser password=javadude
  driverClassName=com.mysql.jdbc.Driver
  url=jdbc:mysql://localhost:3306/javatest?autoReconnect=true/
 
 
  
 http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples-howto.html
 
  Best wishes,
 
  Lutz
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: DBCP ClassCastException

2005-05-09 Thread Dhiren Bhatia
It works if I use org.apache.tomcat.dbcp.dbcp.BasicDataSource.
 I've tried adding all the commons jars to common/lib and it still doesn't 
work with org.apache.commons.dbcp.BasicDataSource. How do you get it to cast 
with your own resource factory? The way I see it, it should be the same 
thing if you're extending from org.apache.commons.dbcp.BasicDataSource.
 Just FYI...Here's what I have in commons/lib:
 commons-collections-3.1.jar* log4j.jar*
commons-dbcp-1.2.1.jar* mysql-connector-java-3.1.7-bin.jar*
commons-pool-1.2.jar* naming-factory-dbcp.jar*
jasper-compiler-jdt.jar* naming-factory.jar*
jasper-compiler.jar* naming-resources.jar*
jasper-runtime.jar* servlet-api.jar*
jsp-api.jar*

 On 5/9/05, Pfingstl Gernot [EMAIL PROTECTED] wrote: 
 
 You can find org.apache.tomcat.dbcp.dbcp.BasicDataSource in 
 common/lib/naming-factory-dbcp.jar.
 If you put commons-dbcp.jar, commons-pool.jar and commons-collections.jarin 
 common/lib you (maybe) should be able to use 
 org.apache.commons.dbcp.BasicDataSource.
 I do it in a similar way - I have my own ressource factory, which extends 
 org.apache.commons.dbcp.BasicDataSourceFactory and it works in tomcat 5.5with 
 the above jars.
 
 Gernot
 
 -Ursprüngliche Nachricht-
 Von: Dhiren Bhatia [mailto:[EMAIL PROTECTED]
 Gesendet: Montag, 09. Mai 2005 18:47
 An: Tomcat Users List
 Betreff: Re: DBCP ClassCastException
 
 I'm using BasicDataSource because javax.sql.DataSource does not have 
 methods
 to set the driver class name, url, username/pwd etc. My app needs to 
 support
 different databases and the driver is loaded based on which database is
 installed.
 If I use org.apache.tomcat.dbcp.dbcp.BasicDataSource, then my code is not
 portable to JBoss/Weblogic etc right? BTW, which jar is
 org.apache.tomcat.dbcp.dbcp.BasicDataSource in?
 Thanks for your response.
 Dhiren
 
 On 5/9/05, Pfingstl Gernot [EMAIL PROTECTED] wrote:
 
  Tomcat 5.5 doesn't use commons-dbcp directly, the tomcat team took the
  source and put it in other packages.
  So you should use org.apache.tomcat.dbcp.dbcp.BasicDataSource instead of
  org.apache.commons.dbcp.BasicDataSource in your source - btw why do you
  cast to BasicDataSource, you can use javax.sql.DataSource?
 
  Gernot
 
  -Ursprüngliche Nachricht-
  Von: Dhiren Bhatia [mailto:[EMAIL PROTECTED]
  Gesendet: Montag, 09. Mai 2005 17:19
  An: Tomcat Users List
  Betreff: Re: DBCP ClassCastException
 
 
  Hi Lutz,
  I changed the Resource tag definition to:
  Resource name=jdbc/myserver auth=Container type=
 javax.sql.DataSource
  
  maxActive=100 maxIdle=30 maxWait=1
  driverClassName=com.mysql.jdbc.Driver/
  I'm setting the username/password and jdbcurl using code.
  I still get the same ClassCastException. Is Tomcat instantiating the
  correct DataSourceFactory?
  I have the commons-dbcp-1.2.1.jar in my ${TOMCAT_HOME}/common/lib
  Thanks,
  Dhiren
 
  On 5/8/05, Lutz Zetzsche [EMAIL PROTECTED] wrote:
  
   Hi Dhiren,
  
   Am Montag, 9. Mai 2005 07:36 schrieb Dhiren Bhatia:
Hi all,
   
I'm getting a the following ClassCastException running Tomcat 5.5.9
with MySQL
   
java.lang.ClassCastException:
org.apache.tomcat.dbcp.dbcp.BasicDataSource
   
Here's the relevant code:
*Java code:*
org.apache.commons.dbcp.BasicDataSource datasource;
   
datasource =
(BasicDataSource)ctx.lookup(java:comp/env/jdbc/myserver);
   
*web.xml*
resource-ref
descriptionDB Connection/description
res-ref-namejdbc/myserver/res-ref-name
res-typejavax.sql.DataSource/res-type
res-authContainer/res-auth
/resource-ref
*server.xml*
**
ResourceParams name=jdbc/myserver
parameter
namefactory/name
valueorg.apache.commons.dbcp.BasicDataSourceFactory/value
/parameter
*...*
   
   
This same code works in Tomcat 5.0.30.
   
Has anything changed? Am I missing something?
  
   Yes. The syntax for the Resource tag in the server.xml has changed. 
 The
   resource parameters are no longer defined in tags nested into the
   Resource tag, but in attributes of the tag. This is an example from 
 the
   Tomcat 5.5 documentation:
  
   Resource name=jdbc/TestDB auth=Container
   type=javax.sql.DataSource maxActive=100 maxIdle=30
   maxWait=1 username=javauser password=javadude
   driverClassName=com.mysql.jdbc.Driver
   url=jdbc:mysql://localhost:3306/javatest?autoReconnect=true/
  
  
  
  
 http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples-howto.html
  
   Best wishes,
  
   Lutz
  
   -
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
  
  
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 -
 To unsubscribe, e-mail

AW: DBCP ClassCastException

2005-05-09 Thread Pfingstl Gernot
My factory:
import org.apache.commons.dbcp.BasicDataSource;
import org.apache.commons.dbcp.BasicDataSourceFactory;

public class MyDataSourceFactory extends BasicDataSourceFactory
{
public Object getObjectInstance(
Object obj,
Name name,
Context nameCtx,
Hashtable environment)
throws Exception
{
BasicDataSource basicDataSource =
(BasicDataSource) super.getObjectInstance(
obj,
name,
nameCtx,
environment);

if ((obj == null) || !(obj instanceof Reference))
{
return (null);
}
Reference ref = (Reference) obj;
if (!javax.sql.DataSource.equals(ref.getClassName()))
{
return (null);
}
// do some stuff here
// ...
return basicDataSource;
}
}

and of course you have to specify this factory in your context.xml (or web.xml)

Gernot

-Ursprüngliche Nachricht-
Von: Dhiren Bhatia [mailto:[EMAIL PROTECTED]
Gesendet: Montag, 09. Mai 2005 19:27
An: Tomcat Users List
Betreff: Re: DBCP ClassCastException


It works if I use org.apache.tomcat.dbcp.dbcp.BasicDataSource.
 I've tried adding all the commons jars to common/lib and it still doesn't
work with org.apache.commons.dbcp.BasicDataSource. How do you get it to cast 
with your own resource factory? The way I see it, it should be the same 
thing if you're extending from org.apache.commons.dbcp.BasicDataSource.
 Just FYI...Here's what I have in commons/lib:
 commons-collections-3.1.jar* log4j.jar*
commons-dbcp-1.2.1.jar* mysql-connector-java-3.1.7-bin.jar*
commons-pool-1.2.jar* naming-factory-dbcp.jar*
jasper-compiler-jdt.jar* naming-factory.jar*
jasper-compiler.jar* naming-resources.jar*
jasper-runtime.jar* servlet-api.jar*
jsp-api.jar*

 On 5/9/05, Pfingstl Gernot [EMAIL PROTECTED] wrote: 
 
 You can find org.apache.tomcat.dbcp.dbcp.BasicDataSource in 
 common/lib/naming-factory-dbcp.jar.
 If you put commons-dbcp.jar, commons-pool.jar and commons-collections.jarin 
 common/lib you (maybe) should be able to use 
 org.apache.commons.dbcp.BasicDataSource.
 I do it in a similar way - I have my own ressource factory, which extends 
 org.apache.commons.dbcp.BasicDataSourceFactory and it works in tomcat 5.5with 
 the above jars.
 
 Gernot
 
 -Ursprüngliche Nachricht-
 Von: Dhiren Bhatia [mailto:[EMAIL PROTECTED]
 Gesendet: Montag, 09. Mai 2005 18:47
 An: Tomcat Users List
 Betreff: Re: DBCP ClassCastException
 
 I'm using BasicDataSource because javax.sql.DataSource does not have 
 methods
 to set the driver class name, url, username/pwd etc. My app needs to 
 support
 different databases and the driver is loaded based on which database is
 installed.
 If I use org.apache.tomcat.dbcp.dbcp.BasicDataSource, then my code is not
 portable to JBoss/Weblogic etc right? BTW, which jar is
 org.apache.tomcat.dbcp.dbcp.BasicDataSource in?
 Thanks for your response.
 Dhiren
 
 On 5/9/05, Pfingstl Gernot [EMAIL PROTECTED] wrote:
 
  Tomcat 5.5 doesn't use commons-dbcp directly, the tomcat team took the
  source and put it in other packages.
  So you should use org.apache.tomcat.dbcp.dbcp.BasicDataSource instead of
  org.apache.commons.dbcp.BasicDataSource in your source - btw why do you
  cast to BasicDataSource, you can use javax.sql.DataSource?
 
  Gernot
 
  -Ursprüngliche Nachricht-
  Von: Dhiren Bhatia [mailto:[EMAIL PROTECTED]
  Gesendet: Montag, 09. Mai 2005 17:19
  An: Tomcat Users List
  Betreff: Re: DBCP ClassCastException
 
 
  Hi Lutz,
  I changed the Resource tag definition to:
  Resource name=jdbc/myserver auth=Container type=
 javax.sql.DataSource
  
  maxActive=100 maxIdle=30 maxWait=1
  driverClassName=com.mysql.jdbc.Driver/
  I'm setting the username/password and jdbcurl using code.
  I still get the same ClassCastException. Is Tomcat instantiating the
  correct DataSourceFactory?
  I have the commons-dbcp-1.2.1.jar in my ${TOMCAT_HOME}/common/lib
  Thanks,
  Dhiren
 
  On 5/8/05, Lutz Zetzsche [EMAIL PROTECTED] wrote:
  
   Hi Dhiren,
  
   Am Montag, 9. Mai 2005 07:36 schrieb Dhiren Bhatia:
Hi all,
   
I'm getting a the following ClassCastException running Tomcat 5.5.9
with MySQL
   
java.lang.ClassCastException:
org.apache.tomcat.dbcp.dbcp.BasicDataSource
   
Here's the relevant code:
*Java code:*
org.apache.commons.dbcp.BasicDataSource datasource;
   
datasource =
(BasicDataSource)ctx.lookup(java:comp/env/jdbc/myserver);
   
*web.xml*
resource-ref
descriptionDB Connection/description
res-ref-namejdbc/myserver/res-ref-name
res-typejavax.sql.DataSource/res-type
res-authContainer/res-auth
/resource-ref

DBCP ClassCastException

2005-05-08 Thread Dhiren Bhatia
Hi all,

I'm getting a the following ClassCastException running Tomcat 5.5.9 with 
MySQL

java.lang.ClassCastException: org.apache.tomcat.dbcp.dbcp.BasicDataSource

Here's the relevant code:
 *Java code:*
org.apache.commons.dbcp.BasicDataSource datasource;

datasource = (BasicDataSource)ctx.lookup(java:comp/env/jdbc/myserver);

*web.xml*
resource-ref
descriptionDB Connection/description
res-ref-namejdbc/myserver/res-ref-name
res-typejavax.sql.DataSource/res-type
res-authContainer/res-auth
/resource-ref
 *server.xml*
**
 ResourceParams name=jdbc/myserver
parameter
namefactory/name
valueorg.apache.commons.dbcp.BasicDataSourceFactory/value
/parameter
*...*


This same code works in Tomcat 5.0.30.

Has anything changed? Am I missing something?

Thanks.