How can I create a JDCB connection pool in Tomcat 4 for MySql?
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Gabriel_Moreno
Posted On:   Thursday, December 6, 2001 01:44 PM

I have a problem with a connection pool that I implement in Tomcat 4 for MySql: server XML: type="javax.sql.DataSource"/> user an_user password a_pass driverClassName org.gjt.mm.mysql.Driver driverName jdbc:mysql://localhost/SepRico web.xml: jdbc/SepRico javax.sql.DataSource Container I use a java class to access the database from a JSP: Context initCtx=new InitialContext(); Context envCtx=(Context   More>>

I have a problem with a connection pool that I implement in Tomcat 4 for MySql:



server XML:




type="javax.sql.DataSource"/>


user an_user

password a_pass

driverClassName
org.gjt.mm.mysql.Driver

driverName
jdbc:mysql://localhost/SepRico







web.xml:







jdbc/SepRico





javax.sql.DataSource





Container







I use a java class to access the database from a JSP:



Context initCtx=new InitialContext();

Context envCtx=(Context)initCtx.lookup("java:comp/env");

DataSource ds=(DataSource)envCtx.lookup("jdbc/SepRico");

con= ds.getConnection();




The method getConnection throws a java.lang.NullPointerException


What´s the problem?



Thanks.

Gabriel.

   <<Less

Re: How can I create a JDCB connection pool in Tomcat 4 for MySql?

Posted By:   Brian_Kielbasa  
Posted On:   Thursday, January 17, 2002 12:16 PM

I made the mistake of placing mm.mysql-2.0.8-bin.jar in the lib directory of my specific application directory instead of the jakarta-tomcat-4.0.1commonlib directory. Once I did that my null connection problems disappeared.

Re: How can I create a JDCB connection pool in Tomcat 4 for MySql?

Posted By:   Bernie_Acs  
Posted On:   Thursday, December 6, 2001 03:31 PM

You could not be closer


String dbURL = "java:comp/env/jdbc/SepRico";

DataSource dbRes = (DataSource)ic.lookup (dbURL);
Connection conn = dbRes.getConnection();
About | Sitemap | Contact