7 messages in com.mysql.lists.javaRe: Connection Problem
FromSent OnAttachments
Tristan O'Tierney27 May 2002 22:42 
Charles Brown27 May 2002 23:15 
Bruce Scharlau28 May 2002 00:55 
Mark Matthews28 May 2002 03:49 
Peter T. Abplanalp28 May 2002 07:48 
Tristan O'Tierney28 May 2002 14:56 
Peter T. Abplanalp28 May 2002 14:59 
Subject:Re: Connection Problem
From:Peter T. Abplanalp (pt@psaconsultants.com)
Date:05/28/2002 07:48:18 AM
List:com.mysql.lists.java

i have a friend who runs debian and we had this problem as well. the skip-networking flag can be found in /etc/my.cnf, iirc.

On Tue, May 28, 2002 at 05:49:45AM -0500, Mark Matthews wrote:

My guess is that if you installed mysql through apt, that it is not listening on any TCP/IP port, and port 3306 is firewalled on your system.

You need to remove the "--skip-networking" flag from your MySQL server startup script (I don't run Debian, so I don't know where that would be), and make sure that you're not firewalling port 3306.

Try "telnet localhost 3306" and see what happens. If that hangs as well, then the port is firewalled.

-Mark

I'm trying to connect to a mysql database through localhost, and i'm getting a strange problem. The server is running just fine, because it's accessable through php and command line, but when i try to use this code:

import java.sql.DriverManager; import java.sql.Connection; import java.sql.SQLException;

public class TestDatabase {

public static void main( String[] args ) { try { Connection conn = null; Class.forName( "org.gjt.mm.mysql.Driver" ).newInstance(); System.out.println ( "Instance created" ); conn = DriverManager.getConnection( "jdbc:mysql://localhost/database", "username", "password" ); System.out.println ( "Connection created" ); conn.close(); System.out.println ( "Connection closed" ); } catch ( SQLException e ) { System.err.println ( "SQL Error #: " + e.getMessage() ); System.err.println ( e.getMessage() ); } catch ( ClassNotFoundException e ) { System.err.println ( "Class Not Found" ); System.err.println ( e.getMessage() ); } catch ( InstantiationException e ) { System.err.println ( "Instantiation Error" ); System.err.println ( e.getMessage() ); } catch ( IllegalAccessException e ) { System.err.println ( "Illegal Access" ); System.err.println ( e.getClass() ); }

System.out.println ( "Exiting" ); System.exit( 0 ); }

} // TestDatabase

All that happens is "Instance created" is printed to std out, and then the program locks up. It never even gets past the DriverManager.getConnection() line. I tried letting it time out incase the connection wasn't working but after a few minutes it was still stuck in that line. I don't even know where to begin to debug this, so I'm hoping someone on the list might know where to at least start?

On a side note, I'm running Debian Linux, and Blackdown Java 1.3.1, with 2.0.14 mm.mysql

Thanks in advance

-Tristan

To unsubscribe, send a message to the address shown in the List-Unsubscribe header of this message. If you cannot see it, e-mail java@lists.mysql.com instead.

To unsubscribe, send a message to the address shown in the List-Unsubscribe header of this message. If you cannot see it, e-mail java@lists.mysql.com instead.