Pretty straightforward stuff, here -- I'm just not good enough with mysql to understand what it wants from me.
I've got a short java test-case that opens a connection on mysql on my dev system but, when I try to put it to my server, it fails.
Any help in tracking this down would be most appreciated.
Thanks!
Test Code
import java.util.*;
import java.sql.*;
public class mysqltest {
static public void getDBConnection() {
System.out.println ("Start of getDBConnection.");
Connection conn = null;
String url = "jdbc:mysql://localhost:3306/";
String dbName = "magnets_development";
String driver = "com.mysql.jdbc.Driver";
String userName = "*****"; // blanked for publication
String password = "*****";
try {
Class.forName (driver).newInstance();
System.out.println ("driver.newInstance gotten.");
conn = DriverManager.getConnection (url+dbName, userName, password);
System.out.println ("Connection gotten: " + conn + ".");
Statement sql = conn.createStatement ();
ResultSet results = sql.executeQuery ("use " + dbName + ";");
}
catch (Exception ex) {
System.out.println ("*** Got exception.");
ex.printStackTrace();
}
}
public static void main(String args[]) {
System.out.println ("Main started.");
mysqltest.getDBConnection();
}
}
Dev System Output (Expected/correct response)
olie$ java mysqltest
Main started.
Start of getDBConnection.
Properties set.
driver.newInstance gotten.
Connection gotten: com.mysql.jdbc.Connection@c980c9.
olie$
Server Output (Error I'm trying to track-down) (Some blank lines removed.)
mini$ java mysqltest
Main started.
Start of getDBConnection.
Properties set.
driver.newInstance gotten.
*** Got exception.
com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:
** BEGIN NESTED EXCEPTION **
java.net.ConnectException
MESSAGE: Connection refused
STACKTRACE:
java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:432)
at java.net.Socket.connect(Socket.java:520)
at java.net.Socket.connect(Socket.java:470)
at java.net.Socket.<init>(Socket.java:367)
at java.net.Socket.<init>(Socket.java:209)
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:256)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:271)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:2771)
at com.mysql.jdbc.Connection.<init>(Connection.java:1555)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:285)
at java.sql.DriverManager.getConnection(DriverManager.java:525)
at java.sql.DriverManager.getConnection(DriverManager.java:140)
at mysqltest.getDBConnection(mysqltest.java:34)
at mysqltest.main(mysqltest.java:49)
** END NESTED EXCEPTION **
Last packet sent to the server was 3 ms ago.
at com.mysql.jdbc.Connection.createNewIO(Connection.java:2847)
at com.mysql.jdbc.Connection.<init>(Connection.java:1555)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:285)
at java.sql.DriverManager.getConnection(DriverManager.java:525)
at java.sql.DriverManager.getConnection(DriverManager.java:140)
at mysqltest.getDBConnection(mysqltest.java:34)
at mysqltest.main(mysqltest.java:49)
mini$