Bug Fix
This commit is contained in:
parent
8856ebe077
commit
ce792b2226
1 changed files with 1 additions and 66 deletions
|
@ -43,7 +43,7 @@ public class Database {
|
|||
public void connect() {
|
||||
try {
|
||||
Class.forName("com.mysql.jdbc.Driver").newInstance();
|
||||
connection = DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database, user, password);
|
||||
connection = DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database + "?useSSL=false", user, password);
|
||||
|
||||
startPool();
|
||||
} catch(Exception e) {
|
||||
|
@ -128,69 +128,4 @@ public class Database {
|
|||
return false;
|
||||
}
|
||||
|
||||
public int executeUpdate(String query, HashMap<Integer, Object> objects) {
|
||||
if(query == null || query.isEmpty())
|
||||
return 0;
|
||||
|
||||
if(!enabled)
|
||||
return 0;
|
||||
|
||||
if(!connected())
|
||||
connect();
|
||||
|
||||
if(!connected())
|
||||
return 0;
|
||||
|
||||
stopPool();
|
||||
try {
|
||||
PreparedStatement statement = connection.prepareStatement(query);
|
||||
for(Map.Entry<Integer, Object> entry : objects.entrySet())
|
||||
statement.setObject(entry.getKey(), entry.getValue());
|
||||
|
||||
int i = statement.executeUpdate();
|
||||
statement.close();
|
||||
startPool();
|
||||
|
||||
return i;
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
startPool();
|
||||
return 0;
|
||||
}
|
||||
|
||||
public ResultSet executeQuery(String query, HashMap<Integer, Object> objects) {
|
||||
if(query == null || query.isEmpty())
|
||||
return null;
|
||||
|
||||
|
||||
if(!enabled)
|
||||
return null;
|
||||
|
||||
if(!connected())
|
||||
connect();
|
||||
|
||||
if(!connected())
|
||||
return null;
|
||||
|
||||
stopPool();
|
||||
try {
|
||||
PreparedStatement statement = connection.prepareStatement(query);
|
||||
for(Map.Entry<Integer, Object> entry : objects.entrySet())
|
||||
statement.setObject(entry.getKey(), entry.getValue());
|
||||
|
||||
ResultSet result = statement.executeQuery();
|
||||
statement.close();
|
||||
startPool();
|
||||
|
||||
return result;
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
startPool();
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Reference in a new issue