java - exe from jar can't access MySQL from localhost -
i have gui application connect mysql through xampp. running netbeans fine, when wrap exe using launch4j jar, can't connect database (it reaches exception though interface still working)
i've choose custom classpath , contains mysql library.
and throws exception:
try { // create our mysql database connection class.forname("com.mysql.jdbc.driver"); conn = drivermanager.getconnection("jdbc:mysql://localhost:3306/vietcombank.db?useunicode=yes&characterencoding=utf-8","admin", "123456789"); } catch (exception e) { system.err.println(e.getmessage()); }
the output of exception com.mysql.jdbc.driver
. if run jar cmd direct location java -jar "d:\network programming\serveratm\dist\serveratm.jar"
run fine. because launch4j didn't include libraries?
thank you.
instead of :
private string url = "jdbc:mysql://localhost/your-database-name";
try use :
private string url = "jdbc:mysql://127.0.0.1/your-database-name";
Comments
Post a Comment