# java connectet mysql-db nicht.



## posi (27. Mrz 2005)

hi ich habe eine klasse programmiert, die was aus einer mysql-db lesen soll. (prog mit gui)


```
class Logintest
{
    private Statement stmt;
    private ResultSet rSet;

	public Logintest()
	{
	}

	public boolean testen(String user, String pw)
	{
      int i=0;
      String p=null;
      String u=null;
      try
      {
      	Class.forName( "com.mysql.jdbc.Driver" );
      }
      catch ( ClassNotFoundException e )
      {
      	Error er = new Error("Fehler beim Treiberladen");
      	er.show();
      	return false;
      }
      try
      {
      	String url="jdbc:mysql://server2:3306/cmail";
      	Connection verbindung = DriverManager.getConnection( url, "root", "");
      	stmt = verbindung.createStatement();
        String sqlQuery = "SELECT * FROM user where username="+user;
        rSet = stmt.executeQuery( sqlQuery );
        while ( rSet.next() )
        {
          i++;
          u=rSet.getString("username");
          p=rSet.getString("pw");
        }
        stmt.close();
        verbindung.close();
        if (i!=0) 
        {
        	if ((user.equals(u))&&(pw.equals(p))) return true;
        	else return false;
        }
        else return false;
      }
      catch (SQLException e)
      {
      	Error err = new Error("Loginüberprüfung ist gescheitert.");
      	System.out.print(e);
      	err.show();
      	return false;
      }
   }
}
```

leider connectet ersich nicht mit der db. am treiber liegt es nicht. kann mir jemand helfen, BITTE!!!!!

cu posi


----------



## posi (27. Mrz 2005)

ich hab mal die Fehlernachricht kopiert.


```
Communications link failure due to underlying exception: 
* BEGIN NESTED EXCEPTION ** 

java.net.SocketException
MESSAGE: java.net.SocketException: Unrecognized Windows Sockets error: 10106: create

STACKTRACE:

java.net.SocketException: java.net.SocketException: Unrecognized Windows Sockets error: 10106: create
	at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:151)
	at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:280)
	at com.mysql.jdbc.Connection.createNewIO(Connection.java:1765)
	at com.mysql.jdbc.Connection.<init>(Connection.java:430)
	at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:268)
	at java.sql.DriverManager.getConnection(DriverManager.java:512)
	at java.sql.DriverManager.getConnection(DriverManager.java:171)
	at Logintest.testen(CMail.java:161)
	at Login.actionPerformed(CMail.java:56)
	at java.awt.Button.processActionEvent(Button.java:382)
	at java.awt.Button.processEvent(Button.java:350)
	at java.awt.Component.dispatchEventImpl(Component.java:3615)
	at java.awt.Component.dispatchEvent(Component.java:3477)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
	at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)


** END NESTED EXCEPTION **
```


----------



## Bleiglanz (29. Mrz 2005)

Firewall??


----------



## KSG9|sebastian (29. Mrz 2005)

falscher port? falsche url?


----------



## posi (31. Mrz 2005)

nee, man sollte halt nicht joe nehmen.


----------



## DP (31. Mrz 2005)

wer is datten?


----------

