*Dias Posted October 18, 2019 Posted October 18, 2019 Ok so my problem it is only one. I can compile and install this server but after all Login crash. So no option to connect and try this project. I was use JDK.12, all what i was found and see was bug on java 1.7 Can someone help fix this error. Quote
LexaKAZAN Posted October 18, 2019 Posted October 18, 2019 public class MySqlConnect { Connection con = null; public MySqlConnect(String host, String port, String user, String password, String db, boolean console) throws Exception { try (Formatter form = new Formatter()) { Class.forName("org.mariadb.jdbc.Driver").getDeclaredConstructor().newInstance(); final String formattedText = form.format("jdbc:mariadb://%1$s:%2$s", host, port).toString(); con = DriverManager.getConnection(formattedText, user, password); try (Statement s = con.createStatement()) { s.execute("CREATE DATABASE IF NOT EXISTS `" + db + "`"); s.execute("USE `" + db + "`"); } } catch (SQLException e) { if (console) { e.printStackTrace(); } else { JOptionPane.showMessageDialog(null, "MySQL Error: " + e.getMessage(), "Connection Error", JOptionPane.ERROR_MESSAGE); } } catch (InstantiationException e) { if (console) { e.printStackTrace(); } else { JOptionPane.showMessageDialog(null, "Instantiation Exception: " + e.getMessage(), "Connection Error", JOptionPane.ERROR_MESSAGE); } } catch (IllegalAccessException e) { if (console) { e.printStackTrace(); } else { JOptionPane.showMessageDialog(null, "Illegal Access: " + e.getMessage(), "Connection Error", JOptionPane.ERROR_MESSAGE); } } catch (ClassNotFoundException e) { if (console) { e.printStackTrace(); } else { JOptionPane.showMessageDialog(null, "Cannot find MySQL Connector: " + e.getMessage(), "Connection Error", JOptionPane.ERROR_MESSAGE); } } } public Connection getConnection() { return con; } public Statement getStatement() { try { return con.createStatement(); } catch (SQLException e) { e.printStackTrace(); System.out.println("Statement Null"); return null; } } } under 12java MySqlConnect.java 1 Quote
*Dias Posted October 19, 2019 Author Posted October 19, 2019 Yes but i was use L2j, maybe i will try with L2j Mobius Quote
*Dias Posted October 19, 2019 Author Posted October 19, 2019 was more easy. work with out problems ;) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.