You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by navaneethan loganathan <na...@gmail.com> on 2006/06/29 01:56:30 UTC

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.

Re: Error while connecting to MySQL database

Posted by David Smith <dn...@cornell.edu>.
Ok..

1. Don't mess with the CLASSPATH.  In all modern version of tomcat, the 
class loading heirarchy should take care of all your needs.

2. File ownership - make sure all of tomcat's files are owned by the 
tomcat user.  Sounds to me the db.properties file is not readable by the 
tomcat user account.  That would account for the NullPointerException 
you note below if Class.forName() is receiving a null parameter as a 
class name.

3. This is totally unrelated to tomcat, but mysql's data files should be 
owned entirely by mysql.  I would also recommend you take a look at the 
init script for mysql under /etc/init.d for details on how the path for 
it's datafiles are determined.  I've seen distributions of mysql where 
/etc/my.cnf is not present and not consulted for settings.

4. I'm sure it's been noted, but org.gjt.mm.mysql.Driver is old and very 
out of date.  You should use com.mysql.jdbc.Driver instead.

--David

navaneethan loganathan wrote:

> Hi
>
> I am sorry, as I did not mention that I have root password for mysql. I
> have entered the root password(for mysql)  in my db.properties file.
> I have specified in CLASSPATH as well for mysql connector in both
> $CATALINA_HOME/bin/setclasspath.sh and also the user's .bash_profile.
>
> Today morning I found the mistake I was making..
> mysql(user) is owner for /var/lib/mysql.
> tomcat(user) is owner for $CATALINA_HOME.
> If I start  tomcat with tomcat ownership and tomcat user, I get this 
> error.
> When I made $CATALINA_HOME to root ownership, and start tomcat with root
> user, Then the application is connecting to the database without any
> problem.
> However, It is working, until the database location is /var/lib/mysql. 
> If I
> change the database location to any other directory and specify in
> /etc/my.cnf file as datadir, Then I will not be able to start MySQL 
> server
> even. The detail of this new error is as below while starting the MySQL
> server with command # service mysqld start:
>
> Timeout error occurred trying to start MySQL Daemon.
> Starting MySQL:                                            [FAILED]
> I checked with /var/lib/mysqld.log file. It says, log as below:
>
> 060629 12:56:36  mysqld started
> 060629 12:56:36 [Warning] Can't create test file
> /data/mysql/swt04db.lower-test
> ^G/usr/libexec/mysqld: Can't change dir to '/data/mysql/' (Errcode: 13)
> 060629 12:56:36 [ERROR] Aborting
>
> 060629 12:56:36 [Note] /usr/libexec/mysqld: Shutdown complete
>
> 060629 12:56:36  mysqld ended
>
> I confirmed that the mysql directory inside the /data/mysql is having the
> ownership of mysql:mysql with appropriate permissions.
>
> Since the / is less disk space , I need to shft the data to /data 
> (900GB).
>
> Any clue please....
>
> On 6/29/06, Gordon Smith <gs...@acrelic.com> wrote:
>
>> If Class.forName throws a null pointer exception, chances are it can't
>> find
>> the driver because you have a Tomcat configuration problem or other
>> classpath-related problem relating to driver setup.  Please check out 
>> the
>> documentation on tomcat.apache.org for the details for your version of
>> Tomcat.
>>
>> As an aside, please consult the MySQL documentation about setting a root
>> password and disabling unneeded accounts in the database.  You are 
>> leaving
>> a
>> gaping security hole in your app by not establishing a root db pwd.
>>
>> Once you put a root pwd in place, there's no reason to share it in this
>> forum as long as you can connect by using that pwd from the MySQL 
>> client.
>>
>> Hope this helps.
>>
>> Cheers,
>> Gordon Smith
>>
>> -----Original Message-----
>> From: navaneethan loganathan [mailto:navaneethl@gmail.com]
>> Sent: Wednesday, June 28, 2006 7:57 PM
>> 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: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>


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


Re: Error while connecting to MySQL database

Posted by navaneethan loganathan <na...@gmail.com>.
Hi

I am sorry, as I did not mention that I have root password for mysql. I
have entered the root password(for mysql)  in my db.properties file.
I have specified in CLASSPATH as well for mysql connector in both
$CATALINA_HOME/bin/setclasspath.sh and also the user's .bash_profile.

Today morning I found the mistake I was making..
mysql(user) is owner for /var/lib/mysql.
tomcat(user) is owner for $CATALINA_HOME.
If I start  tomcat with tomcat ownership and tomcat user, I get this error.
When I made $CATALINA_HOME to root ownership, and start tomcat with root
user, Then the application is connecting to the database without any
problem.
However, It is working, until the database location is /var/lib/mysql. If I
change the database location to any other directory and specify in
/etc/my.cnf file as datadir, Then I will not be able to start MySQL server
even. The detail of this new error is as below while starting the MySQL
server with command # service mysqld start:

Timeout error occurred trying to start MySQL Daemon.
Starting MySQL:                                            [FAILED]
I checked with /var/lib/mysqld.log file. It says, log as below:

060629 12:56:36  mysqld started
060629 12:56:36 [Warning] Can't create test file
/data/mysql/swt04db.lower-test
^G/usr/libexec/mysqld: Can't change dir to '/data/mysql/' (Errcode: 13)
060629 12:56:36 [ERROR] Aborting

060629 12:56:36 [Note] /usr/libexec/mysqld: Shutdown complete

060629 12:56:36  mysqld ended

I confirmed that the mysql directory inside the /data/mysql is having the
ownership of mysql:mysql with appropriate permissions.

Since the / is less disk space , I need to shft the data to /data (900GB).

Any clue please....

On 6/29/06, Gordon Smith <gs...@acrelic.com> wrote:

> If Class.forName throws a null pointer exception, chances are it can't
> find
> the driver because you have a Tomcat configuration problem or other
> classpath-related problem relating to driver setup.  Please check out the
> documentation on tomcat.apache.org for the details for your version of
> Tomcat.
>
> As an aside, please consult the MySQL documentation about setting a root
> password and disabling unneeded accounts in the database.  You are leaving
> a
> gaping security hole in your app by not establishing a root db pwd.
>
> Once you put a root pwd in place, there's no reason to share it in this
> forum as long as you can connect by using that pwd from the MySQL client.
>
> Hope this helps.
>
> Cheers,
> Gordon Smith
>
> -----Original Message-----
> From: navaneethan loganathan [mailto:navaneethl@gmail.com]
> Sent: Wednesday, June 28, 2006 7:57 PM
> 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: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

AW: Error while connecting to MySQL database

Posted by "KHZ (SAW)" <ka...@sawag.com>.
Hi Navaneeth.

Check whether you've an XML file according to your web app in the
conf/Catalina/<host> directory.

When removing the elder web app this file is also removed.

Regards,	Karl-Heinz.


-----Ursprüngliche Nachricht-----
Von: Gordon Smith [mailto:gsmith@acrelic.com] 
Gesendet: Donnerstag, 29. Juni 2006 15:51
An: 'Tomcat Users List'
Betreff: RE: Error while connecting to MySQL database

If Class.forName throws a null pointer exception, chances are it can't find
the driver because you have a Tomcat configuration problem or other
classpath-related problem relating to driver setup.  Please check out the
documentation on tomcat.apache.org for the details for your version of
Tomcat.

As an aside, please consult the MySQL documentation about setting a root
password and disabling unneeded accounts in the database.  You are leaving a
gaping security hole in your app by not establishing a root db pwd.  

Once you put a root pwd in place, there's no reason to share it in this
forum as long as you can connect by using that pwd from the MySQL client.

Hope this helps.

Cheers,
Gordon Smith

-----Original Message-----
From: navaneethan loganathan [mailto:navaneethl@gmail.com] 
Sent: Wednesday, June 28, 2006 7:57 PM
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: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org




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


回复: RE: Error while connecting to MySQL database

Posted by Kyle Wu <bu...@yahoo.com.cn>.
# MySQL database access properties
db.driver = org.gjt.mm.mysql.Driver
db.url = jdbc:mysql://localhost:3306/testdb
db.user = root

well, I guess you should specify "db.driver" attribute as 

db.driver = com.mysql.jdbc.Driver 

for value "org.gjt.mm.mysql.Driver" is obsoleted...

anyway,  the Connector-J's doc would be handy help

Gordon Smith <gs...@acrelic.com> 写道: If Class.forName throws a null pointer exception, chances are it can't find
the driver because you have a Tomcat configuration problem or other
classpath-related problem relating to driver setup.  Please check out the
documentation on tomcat.apache.org for the details for your version of
Tomcat.

As an aside, please consult the MySQL documentation about setting a root
password and disabling unneeded accounts in the database.  You are leaving a
gaping security hole in your app by not establishing a root db pwd.  

Once you put a root pwd in place, there's no reason to share it in this
forum as long as you can connect by using that pwd from the MySQL client.

Hope this helps.

Cheers,
Gordon Smith

-----Original Message-----
From: navaneethan loganathan [mailto:navaneethl@gmail.com] 
Sent: Wednesday, June 28, 2006 7:57 PM
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: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org



 		
---------------------------------
 Mp3疯狂搜-新歌热歌高速下   

RE: Error while connecting to MySQL database

Posted by Gordon Smith <gs...@acrelic.com>.
If Class.forName throws a null pointer exception, chances are it can't find
the driver because you have a Tomcat configuration problem or other
classpath-related problem relating to driver setup.  Please check out the
documentation on tomcat.apache.org for the details for your version of
Tomcat.

As an aside, please consult the MySQL documentation about setting a root
password and disabling unneeded accounts in the database.  You are leaving a
gaping security hole in your app by not establishing a root db pwd.  

Once you put a root pwd in place, there's no reason to share it in this
forum as long as you can connect by using that pwd from the MySQL client.

Hope this helps.

Cheers,
Gordon Smith

-----Original Message-----
From: navaneethan loganathan [mailto:navaneethl@gmail.com] 
Sent: Wednesday, June 28, 2006 7:57 PM
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: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org