I used JDBC without any problems many times, but for some reason it does not work for me on the new server. The code compiles and runs on my main machine, and all libraries (including JDBC) must be compiled into one JAR, which I run.
Base Code:
try
{
Class.forName("com.mysql.jdbc.Driver");
}
catch (ClassNotFoundException e)
{
System.err.println("Cannot load driver...");
e.printStackTrace();
}
try
{
connection = DriverManager.getConnection("jdbc:mysql://localhost/dbname?user=dbuser&password=dbpass");
statement = connection.createStatement();
}
catch (SQLException e)
{
System.err.println("Cannot connect to database...");
e.printStackTrace();
}
Error:
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.mysql.jdbc.Util.stackTraceToString(Util.java:355)
at com.mysql.jdbc.Util.<clinit>(Util.java:120)
at com.mysql.jdbc.NonRegisteringDriver.parseURL(NonRegisteringDriver.java:764)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:325)
at java.sql.DriverManager.getConnection(DriverManager.java:620)
at java.sql.DriverManager.getConnection(DriverManager.java:222)
at com.test.Server.<init>(Server.java:78)
at com.test.Server.main(Server.java:49)
Caused by: java.lang.RuntimeException: Can't load resource bundle due to underlying exception java.util.MissingResourceException: Can't find bundle for base name com.mysql.jdbc.LocalizedErrorMessages, locale en_GB
at com.mysql.jdbc.Messages.<clinit>(Messages.java:61)
... 8 more
Caused by: java.util.MissingResourceException: Can't find bundle for base name com.mysql.jdbc.LocalizedErrorMessages, locale en_GB
at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1539)
at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1278)
at java.util.ResourceBundle.getBundle(ResourceBundle.java:733)
at com.mysql.jdbc.Messages.<clinit>(Messages.java:59)
... 8 more
I've never had such a mistake before, and Google doesn't help at all. I checked the database credentials, port number, etc. I would thank for the help in solving it!
source
share