mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 23:26:45 +01:00
Minor DB tweaks.
This commit is contained in:
parent
6cb2843707
commit
8099490213
@ -196,13 +196,16 @@ public final class DatabaseManager {
|
|||||||
* @return the number of rows affected
|
* @return the number of rows affected
|
||||||
*/
|
*/
|
||||||
public static int update(String sql) {
|
public static int update(String sql) {
|
||||||
int ret = 0;
|
if (!checkConnected()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int rows = 0;
|
||||||
|
|
||||||
if (checkConnected()) {
|
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
try {
|
try {
|
||||||
statement = connection.prepareStatement(sql);
|
statement = connection.prepareStatement(sql);
|
||||||
ret = statement.executeUpdate();
|
rows = statement.executeUpdate();
|
||||||
}
|
}
|
||||||
catch (SQLException ex) {
|
catch (SQLException ex) {
|
||||||
printErrors(ex);
|
printErrors(ex);
|
||||||
@ -217,9 +220,8 @@ public final class DatabaseManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -229,22 +231,21 @@ public final class DatabaseManager {
|
|||||||
* @return the value in the first row / first field
|
* @return the value in the first row / first field
|
||||||
*/
|
*/
|
||||||
public static int getInt(String sql) {
|
public static int getInt(String sql) {
|
||||||
ResultSet resultSet = null;
|
if (!checkConnected()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int result = 0;
|
int result = 0;
|
||||||
|
|
||||||
if (checkConnected()) {
|
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
statement = connection.prepareStatement(sql);
|
statement = connection.prepareStatement(sql);
|
||||||
resultSet = statement.executeQuery();
|
ResultSet resultSet = statement.executeQuery();
|
||||||
|
|
||||||
if (resultSet.next()) {
|
if (resultSet.next()) {
|
||||||
result = resultSet.getInt(1);
|
result = resultSet.getInt(1);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
result = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (SQLException ex) {
|
catch (SQLException ex) {
|
||||||
printErrors(ex);
|
printErrors(ex);
|
||||||
@ -259,7 +260,6 @@ public final class DatabaseManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user