public static int sqlExecuteQueryOneInt(java.sql.Statement stat, String query) { java.sql.ResultSet rs = null; int result = 0; try { rs = stat.executeQuery(query); if (rs.next()) { result = rs.getInt(1); } else { Ts.printErr("There is no result."); } } catch (java.sql.SQLException ex) { Ts.printErr(ex); } return result; } public static double sqlExecuteQueryOneDouble(java.sql.Statement stat, String query) { java.sql.ResultSet rs = null; double result = 0; try { rs = stat.executeQuery(query); if (rs.next()) { result = rs.getDouble(1); } else { Ts.printErr("There is no result."); } } catch (java.sql.SQLException ex) { Ts.printErr(ex); } return result; } public static String sqlExecuteQueryOneString(java.sql.Statement stat, String query) { java.sql.ResultSet rs = null; String result = null; try { rs = stat.executeQuery(query); if (rs.next()) { result = rs.getString(1); } else { Ts.printErr("There is no result."); } } catch (java.sql.SQLException ex) { Ts.printErr(ex); } return result; } public static void printErr(java.sql.SQLException ex) { System.out.println("SQL State: " + ex.getSQLState()); System.out.println("Error Code: " + ex.getErrorCode()); Ts.printErr((java.lang.Exception) ex); } public static void printErr(java.lang.Exception ex) { ex.printStackTrace(); System.exit(-1); }