Hello,
I'm having trouble with mysql when using x10 hosting. For some reason i continue to get the error. Unable to connect to host on my cmd. Although when i run from localhost on xxamp it works fine. I'l give you a snippet of code and see if u can find the problem.
Settings
Database Manager
All help is appreciated thanks.
I'm having trouble with mysql when using x10 hosting. For some reason i continue to get the error. Unable to connect to host on my cmd. Although when i run from localhost on xxamp it works fine. I'l give you a snippet of code and see if u can find the problem.
Settings
Code:
public static final String DB_HOST = "198.91.81.2";
public static final String DB_USER = "kanesemp_server";
public static final String DB_PASS = "dasdasdsadasdasd";
public static final String DB_NAME = "kanesemp_server";
Database Manager
Code:
package org.kanesempire.engine.mysql;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import org.kanesempire.GameServer;
import org.kanesempire.Settings;
public class DatabaseManager {
private String host;
private String database;
private String username;
private String password;
private Connection connection;
private Statement statement;
private boolean connected;
public DatabaseManager() {
this.host = Settings.DB_HOST;
this.database = Settings.DB_NAME;
this.username = Settings.DB_USER;
this.password = Settings.DB_PASS;
this.connected = false;
}
public void connect() {
try {
connection = DriverManager.getConnection("jdbc:mysql://" + host + "/" + database + "?jdbcCompliantTruncation=false", username, password);
statement = connection.createStatement();
GameServer.get().logger().parent("Successfully connected with " + host + "/" + database);
connected = true;
} catch (Exception e) {
GameServer.get().logger().parent("Unable to connect with " + host + "/" + database + ".");
connected = false;
}
}
public ResultSet executeQuery(String query) {
try {
if (!connected())
return null;
statement = connection.createStatement();
ResultSet results = statement.executeQuery(query);
return results;
} catch (Exception e) {
GameServer.get().logger().error(e);
}
return null;
}
public int executeUpdate(String query) {
try {
if (!connected())
return 0;
statement = connection.createStatement();
return statement.executeUpdate(query);
} catch (Exception e) {
GameServer.get().logger().error(e);
}
return 0;
}
public boolean connected() {
return connected;
}
public Statement statement() {
return statement;
}
}
All help is appreciated thanks.