SQLException: Communications link failure
Error:
Code:
SQLException: Communications link failure
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
SQLState: 08S01
VendorError: 0
Relivant Code
Code:
public Main() {
initComponents();
setVisible(true);
progress("Checking Files",true,0);
if(!FileTest("C:/EPOS_SQL/mysql-connector-java-5.1.7/mysql-connector-java-5.1.7-bin.jar"))
{ UnZip unZip = new UnZip("C:/EPOS_SQL", "MySQL - EPOS.zip");}
progress("Starting Database", true);
try {
JarFileLoader.addFile("C:/EPOS_SQL/mysql-connector-mxj-gpl-5-0-9/mysql-connector-mxj-gpl-5-0-9.jar");
JarFileLoader.addFile("C:/EPOS_SQL/mysql-connector-mxj-gpl-5-0-9/mysql-connector-mxj-gpl-5-0-9-db-files.jar");
JarFileLoader.addFile("C:/EPOS_SQL/mysql-connector-mxj-gpl-5-0-9/lib/aspectjrt.jar");
JarFileLoader.addFile("C:/EPOS_SQL/mysql-connector-java-5.1.7/mysql-connector-java-5.1.7-bin.jar");
int port = Integer.parseInt(System.getProperty("c-mxj_test_port", "3336"));
Class.forName("com.mysql.jdbc.Driver");
[COLOR="Red"] conn = DriverManager.getConnection("jdbc:mysql:mxj:///test?"
+ "user=monty&password=greatsqldb")[/COLOR];
progress("Starting Up", true, 0);
open(new EPOS.Log_In(this), false);
progress("", false, 0);
} catch (IOException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
} catch (SQLException ex) {
System.out.println("SQLException: " + ex.getMessage());
System.out.println("SQLState: " + ex.getSQLState());
System.out.println("VendorError: " + ex.getErrorCode());
dispose();
} catch (Exception ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
ResultSet rs = Select("SELECT COUNT(*)FROM information_schema.tables WHERE table_schema = 'EPOS' AND table_name = 'LogIn';");
if(!FileTest("C:/EPOS_SQL/mysql-connector-java-5.1.7/mysql-connector-java-5.1.7-bin.jar"))
open(new EPOS.Log_In(this), false);
else
open(new EPOS.NewBusniess.Customer(this),false);
}
The line in red starts the databse connection. However it always throws an error and is null. Can't find out how to fix it >.<