1

I am trying to connect one PC (with XAMPP) with another PC (with Processing). For this, I downloaded a MySQL library for Processing: import de.bezier.data.sql.*;

It works when I use localhost as a server, it works with other computers when both have internet. However, I need this to work in a local network, so no internet and just the router's wireless connection. And here it fails. I have no idea why. Even when I use the LAN cable, I can access the 'server' via URL. But when I want to access it in Processing I get this:

SQL.connect(): Could not connect to the database ( jdbc:mysql://192.168.0.103/event ).

com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception: 

** BEGIN NESTED EXCEPTION ** 

java.net.SocketException
MESSAGE: java.net.ConnectException: Connection timed out: connect

STACKTRACE:

java.net.SocketException: java.net.ConnectException: Connection timed out: connect
    at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:156)
    at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:284)
    at com.mysql.jdbc.Connection.createNewIO(Connection.java:2569)
    at com.mysql.jdbc.Connection.<init>(Connection.java:1485)
    at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
    at java.sql.DriverManager.getConnection(DriverManager.java:582)
    at java.sql.DriverManager.getConnection(DriverManager.java:185)
    at de.bezier.data.sql.SQL.connect(Unknown Source)
    at MySQL_example1.setup(MySQL_example1.java:56)
    at processing.core.PApplet.handleDraw(PApplet.java:2103)
    at processing.core.PGraphicsJava2D.requestDraw(PGraphicsJava2D.java:190)
    at processing.core.PApplet.run(PApplet.java:2006)
    at java.lang.Thread.run(Thread.java:662)


** END NESTED EXCEPTION **



Last packet sent to the server was 26 ms ago.
    at com.mysql.jdbc.Connection.createNewIO(Connection.java:2643)
    at com.mysql.jdbc.Connection.<init>(Connection.java:1485)
    at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
    at java.sql.DriverManager.getConnection(DriverManager.java:582)
    at java.sql.DriverManager.getConnection(DriverManager.java:185)
    at de.bezier.data.sql.SQL.connect(Unknown Source)
    at MySQL_example1.setup(MySQL_example1.java:56)
    at processing.core.PApplet.handleDraw(PApplet.java:2103)
    at processing.core.PGraphicsJava2D.requestDraw(PGraphicsJava2D.java:190)
    at processing.core.PApplet.run(PApplet.java:2006)
    at java.lang.Thread.run(Thread.java:662)

How do I get this to work? Any kind of help is appreciated!

EDIT: The code is basically the example from the library. I changed password, username and the IP adress I want to communicate with. 'event' is the database, 'db_name' the table.

    import de.bezier.data.sql.*;


// created 2005-05-10 by fjenett
// updated fjenett 20081129


MySQL msql;


void setup()
{
    size( 100, 100 );

    // this example assumes that you are running the 
    // mysql server locally (on "localhost").
    //

    // replace --username--, --password-- with your mysql-account.
    //
    String user     = "user123";
    String pass     = "1234";

    // name of the database to use
    //
    String database = "event";
    // add additional parameters like this:
    // bildwelt?useUnicode=true&characterEncoding=UTF-8

    // connect to database of server "localhost"
    //
    msql = new MySQL( this, "192.168.0.103", database, user, pass );

    if ( msql.connect() )
    {
        msql.query( "SELECT COUNT(*) FROM db_name" );
        msql.next();
        int rand = int(random(msql.getInt(1)));

        println( "randomrow: " + msql.getInt(1) );
    }
    else
    {
        // connection failed !
    }
}

void draw()
{
    // i know this is not really a visual sketch ...
}

EDIT2: Could it be that the PC with XAMPP has to activate Telnet Server Services first?

kellz
  • 11
  • 3

1 Answers1

0

Ok, for everyone having the same problem in the future: The computer with XAMPP may have given me all rights to the MySQL database, the computer itself however didn't allow access to any other computers. It's just a temporary solution, but I turned of the Windows Firewall on the computer with XAMPP and it worked.

kellz
  • 11
  • 3