jdbc mysql

Hallo Leute,

ich verstehe die Fehlermeldung nicht

Mein source:

/*
~ * Created on Sep 5, 2004
~ *
~ * TODO To change the template for this generated file go to
~ * Window - Preferences - Java - Code Style - Code Templates
~ */
package masc;

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

/**
~ * @author locutus
~ *
~ * TODO To change the template for this generated type comment go to
~ * Window - Preferences - Java - Code Style - Code Templates
~ */
public class JMySqlDemo {

  public JMySqlDemo() {
    Connection conn = null;
    try {
      Class.forName("com.mysql.jdbc.Driver");
    } catch (ClassNotFoundException e) {
      e.printStackTrace();
    }
    try {
      conn = DriverManager.getConnection( "jdbc:mysql://localhost/rolapp",
"root", "*****" );
    } catch (SQLException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    }
    try {
      conn.close();
    } catch (SQLException e2) {
      // TODO Auto-generated catch block
      e2.printStackTrace();
    }
  }
  public static void main(String args) {
    JMySqlDemo sd = new JMySqlDemo();
  }
}

Die Fehlermeldung:

java.sql.SQLException: Unable to connect to any hosts due to exception:
java.net.ConnectException: Connection refused

Auf Shell klappt die Verbindung doch:

locutus(a)asterix:~$ mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5 to server version: 4.0.20-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

use rolapp;

Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

select * from dummy

~ -> ;
Empty set (0.00 sec)

Hat jemand eine Ahnung, muß ich bei MySql noch was freigeben?

Gruß
Marco

vielleicht verbindet sich die shell ueber unix domain sockets und
dein jdbc programm ueber tcp/ip?

check mal ob mysql tcp/ip verbindungen akzeptiert...

oder vielleicht ist's auch nur was viel simpleres :slight_smile:
bye, chris.

Danke in der my.cnf war die Lösung

# The skip-networking option will no longer be set via debconf menu.
# You have to manually change it if you want networking i.e. the server
# listening on port 3306. The default is "disable" - for security reasons.
#skip-networking

Gruß
Marco

Chris Mair wrote: