You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Sulabh Nangalia <su...@rediffmail.com> on 2004/07/03 09:30:56 UTC

Connection failed when connecting to MySQL server

I have tomcat-4.1.18 server and mysql-3.23.52 server on the same machine (RedHat Linux 8)
In my webapps/application/WEB_INF/lib/ folder, I have 2 .jar files. One is myapplication .jar and other is JConnector(downloaded from mysql.com).
One of the files in my application contains the following lines:

Class.forName("com.mysql.jdbc.Driver").newInstance();

Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/?user=username&password=password");

But whenever I try to open my .jsp page, the Connection fails to the Tomcat Server and after that no other page opens. i.e the server itself crashes.

I tried the following change:
Connection conn = DriverManager.getConnection("jdbc:mysql://192.168.100.38:3306/?user=username&password=password");
But the problem remains.
Can anyone help me urgently.
Thanks in advance.
Sulabh

Re: Connection failed when connecting to MySQL server

Posted by Jorge Salido <js...@gmail.com>.
You could try writing your code inside a try / catch pair to try to
avoid a crash or something like that, and if your code fails, let it
print any error message the exception generates...

Jorge



On 3 Jul 2004 07:30:56 -0000, Sulabh Nangalia <su...@rediffmail.com> wrote:
> I have tomcat-4.1.18 server and mysql-3.23.52 server on the same machine (RedHat Linux 8)
> In my webapps/application/WEB_INF/lib/ folder, I have 2 .jar files. One is myapplication .jar and other is JConnector(downloaded from mysql.com).
> One of the files in my application contains the following lines:
> 
> Class.forName("com.mysql.jdbc.Driver").newInstance();
> 
> Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/?user=username&password=password");
> 
> But whenever I try to open my .jsp page, the Connection fails to the Tomcat Server and after that no other page opens. i.e the server itself crashes.
> 
> I tried the following change:
> Connection conn = DriverManager.getConnection("jdbc:mysql://192.168.100.38:3306/?user=username&password=password");
> But the problem remains.
> Can anyone help me urgently.
> Thanks in advance.
> Sulabh

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