-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Todd O'Bryan wrote:
| I've managed to get mysql up and running again (I don't know how) but
| JDBC won't connect to it.
|
| Here's my little simple code:
| ------------------------------------------------
| import java.sql.*;
| import java.io.*;
|
| public class MySQLTester {
|
|     public static void main(String[] args) throws Exception {
|         Class.forName("com.mysql.jdbc.Driver");
|         System.out.println("Loaded Driver...");
|
|         DriverManager.setLogWriter(new PrintWriter(System.out));
|
|
|         Connection con =
| DriverManager.getConnection("jdbc:mysql://localhost/test","tobryan1",
| "aoeuidhtns");
|         System.out.println("Got connection...");
|
|         Statement s = con.createStatement();
|         s.executeUpdate("CREATE TABLE students (login char(8), last
| VARCHAR(20), first VARCHAR(20), " +
|                         "nickname VARCHAR(20), course CHAR(4), period
| INT)");
|     }
| }
| ------------------------
| And here's what happens:
|
| [iBook:18]> java MySQLTester
| Loaded Driver...
| DriverManager.getConnection("jdbc:mysql://localhost/test")
|     trying
| driver[className=com.mysql.jdbc.Driver,[EMAIL PROTECTED]
|
| and it hangs forever.
|
| -------------------------
| I can connect to mysql using the same user name and password, however....
|
| [iBook:20]> mysql -u tobryan1 -p
| Enter password:
| Welcome to the MySQL monitor.  Commands end with ; or \g.
| Your MySQL connection id is 9 to server version: 4.0.12-standard
|
| Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
|
| mysql> use test;
| Database changed
| mysql> show tables;
| Empty set (0.00 sec)
|
| mysql>
| -------------------------
| I've searched for info on troubleshooting the JDBC connection and
| skimmed the O'Reilly book by George Reese, but to no avail.
|
| Should I just give up, or is there something I can do to figure out
| what's going wrong?
|
| Thanks,
| Todd


When you don't specify a hostname (and 'localhost' doesn't count, use '127.0.0.1') to the mysql commandline client, it uses Unix domain sockets to connect to the server.

JDBC has to use TCP/IP, because Java doesn't have support for Unix
domain sockets.

What happens if you do:

mysql -h 127.0.0.1 -u tobryan1 -p

What happens if you telnet to 'localhost 3306'...does the server answer,
or do you just sit forever?

If neither of these work, than neither will JDBC...do you have a
firewall setup on your machine that would block 127.0.0.1? Was mysqld
started with '--skip-networking' ???

-Mark


- -- MySQL 2003 Users Conference -> http://www.mysql.com/events/uc2003/

For technical support contracts, visit https://order.mysql.com/?ref=mmma

~    __  ___     ___ ____  __
~   /  |/  /_ __/ __/ __ \/ /  Mark Matthews <[EMAIL PROTECTED]>
~  / /|_/ / // /\ \/ /_/ / /__ MySQL AB, Full-Time Developer - JDBC/Java
~ /_/  /_/\_, /___/\___\_\___/ Flossmoor (Chicago), IL USA
~        <___/ www.mysql.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQE+iwg5tvXNTca6JD8RAuwwAKC86/iQI35O+DYV89O4bAdDnDf8zACgma1w
HdDjewEWMRj5/0gYmM9MARo=
=ay/F
-----END PGP SIGNATURE-----


-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to