tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Campbell <sea...@halcyon.com>
Subject Re: Repost: Can't connect to a running network-enabled mysql server on localhost
Date Thu, 09 Jan 2003 05:50:31 GMT
You might start mysql with --log and see if that gives more info.

At 10:26 AM 1/9/2003 +0800, you wrote:
>Since I didn't get a response the first time round, and I CAN'T believe
>that nobody has ever run into this before, and I can't find what I'm
>looking for in the FAQ or the archive, and the doc. for tomcat4 seems to
>be pretty much non-existent, and the notes with mm.mysql don't help,
>I'll ask again...
>
>I'm running tomcat 4.0.3 on debian woody with apache and mysql on the
>same box.  I can connect to mysql from another machine via tcp/ip on
>port 3306, and from perl and php4 scripts.
>
>When I try this code under tomcat, i get an error about 'can't find a
>mysql server on port 3306'
>
>%<-------------------------------------------------------
><%@ page import="java.sql.*" %> 
>Last Name First Name 
><% Connection conn = null; Statement st = null; ResultSet rs = null; try { Class.forName("org.gjt.mm.mysql.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://localhost/cartapp?user=root"); } catch(Exception
ex) { out.println("Exception handler!"); out.println(ex); } finally { if(rs!=null)rs.close();
if(st!=null)st.close(); if(conn!=null)conn.close(); } %> 
>%<--------------------------------------------------------------------
>
>but equivalent code (below) works just fine with pure java...
>
>%<--------------------------------------------------------------------
>
>import java.sql.*;
>
>class HelloWorldApp {
>    public static void main(String[] args) throws java.sql.SQLException{
>        Connection conn = null;
>        Statement  st   = null;
>        ResultSet  rs   = null;
>
>        try
>        {
>          Class.forName("org.gjt.mm.mysql.Driver").newInstance();
>          conn =
>DriverManager.getConnection("jdbc:mysql://localhost/cartapp?user=root");
>          st   = conn.createStatement();
>          rs   = st.executeQuery("select * from employees");
>
>          while (rs.next()) {
>            System.out.println(rs.getString("lname_txt"));
>          }
>        }
>        catch (Exception ex)
>        {
>          ex.printStackTrace();
>        }
>        finally
>        {
>          if( rs   != null) rs.close();
>          if( st   != null) st.close();
>          if( conn != null) conn.close();
>        }
>        
>        System.out.println("Hello World!"); // Display "Hello World!"
>    }
>}
>
>%<--------------------------------------------------------------------
>
>Has anyone had any similar issues, and can point me in the right
>direction?
>
>-- 
>Regards,
>
>John Breen
>
>+---------------------------------------------------------+-------------+
>|  aaaa   pppppp   aaaa   n nnnn   aaaa   ww   ww  aaaa   |            
>|
>|     aa   pp   p     aa   nn  nn     aa  ww   ww     aa  | John Breen 
>|
>|  aaaaa   pp   p aaaaaa   nn  nn aaaaaa  ww w ww  aaaaa  | Coordinator
>|
>| a   aa   ppppp  a   aa   nn  nn a   aa  ww w ww a   aa  | APANA, Inc.
>|
>|  aaaa a  pp      aaaa a nnn nnn  aaaa a  wwwww   aaaa a | WA Region  
>|
>|         pppp                                            |            
>|
>+---------------------------------------------------------+-------------+
>                      email: locutus@borg.apana.org.au
>
>
>--
>To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
>For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


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


Mime
View raw message