Hi,

I don't' know whether specifying db.properties works or not, but I
configured a datasource for mysql as follows:
1. Shutdown tomcat.
2. Enter followin in TOMCAT_HOME/conf/server.xml
(If you have an entry in server.xml for this update it as below)
    <Resource
      name="jdbc/MyDB"
      type="javax.sql.DataSource"
      driverClassName="org.gjt.mm.mysql.Driver"
      factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
      maxActive="10"
      maxIdle="1"
      maxWait="5000"
      minIdle="1"
      initialSize="10"
      validationQuery="select 1"
      username="root"
      password=""
      url="jdbc:mysql://localhost/testdb"
      />

3. Enter following in your-web-app/META-INF/context.xml file
  <ResourceLink
    debug="5"
    name="jdbc/MyDB"
    global="jdbc/MyDB"
    type="javax.sql.DataSource"/>
4. Enter in your-web-app/WEB-INF/web.xml following 
        <resource-ref>
                <res-ref-name>jdbc/MyDB</res-ref-name>
                <res-type>javax.sql.DataSource</res-type>
                <res-auth>Container</res-auth>
        </resource-ref>
5. Then in you code use the JNDI lookup to get the datasourec and
connetion as useual.
 
Regards,
Jitendra 

-----Original Message-----
From: navaneethan loganathan [mailto:[EMAIL PROTECTED] 
Sent: Thursday, June 29, 2006 5:27 AM
To: users@tomcat.apache.org
Subject: Error while connecting to MySQL database

Hi,

I am facing a problem with my Apache-Tomcat-MySQL
installation.MyEnvironment is as follows:
Redhat ES4(2.6.9-5.EL), Apache-Tomcat-5.5.15, MySQL 4.1.12, Java version
1.5.0_06, Apache-Tomcat connector ajp13,
mysql-connector-java-3.2.0-alpha-bin.jar.

After installation and configuration I am unable to connect to the
database through the application and getting the following exception in
catalina.outlog file.

java.lang.NullPointerException
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:164)

However, I am able to browse my site perfectly with
http://localhost/index.jsp (the connector also configured perfectly, so
that I do not need to specify the port number in URL).
 I put the mysql-connector-java-3.2.0-alpha-bin.jar file in
$CATALINA_HOME/common/lib and also specified in CLASSPATH.

I am able to login to MySQL through command and access the database
without any problem.

My db.properties is as under:

# MySQL database access properties
db.driver = org.gjt.mm.mysql.Driver
db.url = jdbc:mysql://localhost:3306/testdb
db.user = root
db.pwd =
Any clue will be very much helpfull.Thanks in advance.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to