You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by seant <se...@vsnl.com> on 2001/12/27 20:39:35 UTC

Problem in accessing MYSQL *Urgent*

Hi....I need your Urgent Help...
I am facing the following problem while accessing MYSQL through JSP.
I am using TOMCAT,Win 2K,IIS. Normal JSP files are running fine. But when coming to JSP files with Database coding, its giving following Error.
"javax.servlet.ServletException: Cannot connect to MySQL server on localhost:3306. Is there a MySQL server running on the machine/port you are trying to connect to? (java.net.ConnectException)"

When I cheek "services" MYSQL is started and running.  and IIS webserver is also running. 
I had loaded MYSQL drivers in tomcat/common/common/classes directory.
When I check for the version in MYSQLadmin (i.e.. c:Mysql/bin>Mysqladmin version) its giving me the bellow results.

Server Version                         3.23.40-nt
Protocal Version                      10
Connection                              . via named Pipe
UNIX Socket                            MYSQL
Uptime                                    16 days .......

** How do one can know the port number that MYSQL is running on?

And my JSP code is like this .... (Error is coming in this part only)

<!--Main JSP coding Starts From Here-->
   <%@ page import ="java.util.Date"%>
   <%@ page language="java" import="java.sql.*" %>
   <%
   Class.forName("org.gjt.mm.mysql.Driver");
   Connection myConn =  DriverManager.getConnection("jdbc:mysql:///TestDb?user=&password=");
   Statement stmt = myConn.createStatement();
   
   
   out.println("its Connected with out errors.");
   %>
  <!--Main JSP coding Ends Here-->   
   

any advice / help I can get is greatly appreciated....
Thanks in advance...

Seant






Re: Problem in accessing MYSQL *Urgent*

Posted by dn...@cornell.edu.
If you are using a default setup of MySQL, the port
being used is right and it should be listening on the
port.  I would try to connect to the database with a
standard MySQL command line client to see what the JDBC
driver sees.  Also, do you have any firewalls in
operation?  If so, be sure there's a hole there for
connections from localhost to port 3306.

The MySQL JDBC driver does not use UNIX sockets (named
pipes) to talk with the server like your WinMYSQLadmin
does, so the admin program isn't a fair test of
connectivity.

Just a couple of ideas to check out.  Hope this helps
and have a Happy New Year!

--David

Quoting  GregorKovac( <gr...@mikropis.si>:

> Hi!
> 
> since you are using NT version, you can use
WinMySQLAdmin program to 
> determine all what you want to know.
> The port number is located in the Variables tab and
you can set if in 
> my.cnf or my.ini files.
> 
> Best regards,
> 
> 	Kovi
> 
> seant wrote:
> 
> > Hi....I need your Urgent Help...
> > I am facing the following problem while accessing
MYSQL through JSP.
> > I am using TOMCAT,Win 2K,IIS. Normal JSP files are
running fine. But when
> coming to JSP files with Database coding, its giving
following Error.
> > "javax.servlet.ServletException: Cannot connect to
MySQL server on
> localhost:3306. Is there a MySQL server running on the
machine/port you are
> trying to connect to? (java.net.ConnectException)"
> > 
> > When I cheek "services" MYSQL is started and
running.  and IIS webserver
> is also running. 
> > I had loaded MYSQL drivers in
tomcat/common/common/classes directory.
> > When I check for the version in MYSQLadmin (i.e..
c:Mysql/bin>Mysqladmin
> version) its giving me the bellow results.
> > 
> > Server Version                         3.23.40-nt
> > Protocal Version                      10
> > Connection                              . via named Pipe
> > UNIX Socket                            MYSQL
> > Uptime                                    16 days
.......
> > 
> > ** How do one can know the port number that MYSQL is
running on?
> > 
> > And my JSP code is like this .... (Error is coming
in this part only)
> > 
> > <!--Main JSP coding Starts From Here-->
> >    <%@ page import ="java.util.Date"%>
> >    <%@ page language="java" import="java.sql.*" %>
> >    <%
> >    Class.forName("org.gjt.mm.mysql.Driver");
> >    Connection myConn = 
>
DriverManager.getConnection("jdbc:mysql:///TestDb?user=&password=");
> >    Statement stmt = myConn.createStatement();
> >    
> >    
> >    out.println("its Connected with out errors.");
> >    %>
> >   <!--Main JSP coding Ends Here-->   
> >    
> > 
> > any advice / help I can get is greatly appreciated....
> > Thanks in advance...
> > 
> > Seant
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> 
> 
> 
> --
> To unsubscribe:  
<ma...@jakarta.apache.org>
> For additional commands:
<ma...@jakarta.apache.org>
> Troubles with the list:
<ma...@jakarta.apache.org>
> 
> 


--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>


Re: Problem in accessing MYSQL *Urgent*

Posted by " <gregor.kovac@mikropis.si>" <Gregor>.
Hi!

since you are using NT version, you can use WinMySQLAdmin program to 
determine all what you want to know.
The port number is located in the Variables tab and you can set if in 
my.cnf or my.ini files.

Best regards,

	Kovi

seant wrote:

> Hi....I need your Urgent Help...
> I am facing the following problem while accessing MYSQL through JSP.
> I am using TOMCAT,Win 2K,IIS. Normal JSP files are running fine. But when coming to JSP files with Database coding, its giving following Error.
> "javax.servlet.ServletException: Cannot connect to MySQL server on localhost:3306. Is there a MySQL server running on the machine/port you are trying to connect to? (java.net.ConnectException)"
> 
> When I cheek "services" MYSQL is started and running.  and IIS webserver is also running. 
> I had loaded MYSQL drivers in tomcat/common/common/classes directory.
> When I check for the version in MYSQLadmin (i.e.. c:Mysql/bin>Mysqladmin version) its giving me the bellow results.
> 
> Server Version                         3.23.40-nt
> Protocal Version                      10
> Connection                              . via named Pipe
> UNIX Socket                            MYSQL
> Uptime                                    16 days .......
> 
> ** How do one can know the port number that MYSQL is running on?
> 
> And my JSP code is like this .... (Error is coming in this part only)
> 
> <!--Main JSP coding Starts From Here-->
>    <%@ page import ="java.util.Date"%>
>    <%@ page language="java" import="java.sql.*" %>
>    <%
>    Class.forName("org.gjt.mm.mysql.Driver");
>    Connection myConn =  DriverManager.getConnection("jdbc:mysql:///TestDb?user=&password=");
>    Statement stmt = myConn.createStatement();
>    
>    
>    out.println("its Connected with out errors.");
>    %>
>   <!--Main JSP coding Ends Here-->   
>    
> 
> any advice / help I can get is greatly appreciated....
> Thanks in advance...
> 
> Seant
> 
> 
> 
> 
> 
> 
> 



--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>