List of usage examples for java.sql SQLException toString
public String toString()
From source file:dbProcs.Getter.java
/** * @param ApplicationRoot The current running context of the application * @param userName The username of the user * @return The user id of the submitted user name *//*w w w . j av a 2s .c o m*/ public static String getUserIdFromName(String ApplicationRoot, String userName) { log.debug("*** Getter.getUserIdFromName ***"); String result = new String(); Connection conn = Database.getCoreConnection(ApplicationRoot); try { CallableStatement callstmt = conn.prepareCall("call userGetIdByName(?)"); log.debug("Gathering userGetIdByName ResultSet"); callstmt.setString(1, userName); ResultSet resultSet = callstmt.executeQuery(); log.debug("Opening Result Set from userGetIdByName"); resultSet.next(); result = resultSet.getString(1); } catch (SQLException e) { log.error("Could not execute query: " + e.toString()); result = null; } Database.closeConnection(conn); log.debug("*** END getUserIdFromName ***"); return result; }
From source file:dbProcs.Getter.java
/** * @param ApplicationRoot The current running context of the application * @param userId The identifier of a user * @return The user name of the submitted user identifier *//* ww w.ja v a 2s . co m*/ public static String getUserName(String ApplicationRoot, String userId) { log.debug("*** Getter.getUserName ***"); String result = new String(); Connection conn = Database.getCoreConnection(ApplicationRoot); try { CallableStatement callstmt = conn.prepareCall("call userGetNameById(?)"); log.debug("Gathering userGetNameById ResultSet"); callstmt.setString(1, userId); ResultSet resultSet = callstmt.executeQuery(); log.debug("Opening Result Set from userGetNameById"); resultSet.next(); result = resultSet.getString(1); } catch (SQLException e) { log.error("Could not execute query: " + e.toString()); result = null; } Database.closeConnection(conn); log.debug("*** END getUserName ***"); return result; }
From source file:dbProcs.Getter.java
/** * Convert module hash to ID// w w w. j a v a 2 s . c o m * @param ApplicationRoot The current running context of the application * @param moduleHash The module hash to use for look up * @return The identifier of the module with the module hash of the moduleHash parameter */ public static String getModuleIdFromHash(String ApplicationRoot, String moduleHash) { log.debug("*** Getter.getModuleIdFromHash ***"); log.debug("Getting ID from Hash: " + moduleHash); String result = new String(); Connection conn = Database.getCoreConnection(ApplicationRoot); try { CallableStatement callstmt = conn.prepareCall("call moduleGetIdFromHash(?)"); log.debug("Gathering moduleGetIdFromHash ResultSet"); callstmt.setString(1, moduleHash); ResultSet resultSet = callstmt.executeQuery(); log.debug("Opening Result Set from moduleGetIdFromHash"); resultSet.next(); result = resultSet.getString(1); } catch (SQLException e) { log.error("Could not execute query: " + e.toString()); result = null; } Database.closeConnection(conn); log.debug("*** END getModuleIdFromHash ***"); return result; }
From source file:dbProcs.Getter.java
/** * Used to determine if a user has completed a module already * @param ApplicationRoot The current running context of an application * @param moduleId The module identifier * @param userId The user identifier/*from ww w .ja v a 2 s .co m*/ * @return The module name of the module IF the user has not completed AND the user has previously opened the challenge. */ public static String checkPlayerResult(String ApplicationRoot, String moduleId, String userId) { log.debug("*** Getter.checkPlayerResult ***"); String result = null; Connection conn = Database.getCoreConnection(ApplicationRoot); try { log.debug("Preparing userCheckResult call"); CallableStatement callstmnt = conn.prepareCall("call userCheckResult(?, ?)"); callstmnt.setString(1, moduleId); callstmnt.setString(2, userId); log.debug("Executing userCheckResult"); ResultSet resultSet = callstmnt.executeQuery(); resultSet.next(); result = resultSet.getString(1); } catch (SQLException e) { log.debug("userCheckResult Failure: " + e.toString()); result = null; } Database.closeConnection(conn); log.debug("*** END checkPlayerResult ***"); return result; }
From source file:dbProcs.Getter.java
/** * Returns the result key for a module using the module's hash for the lookup procedure. * @param ApplicationRoot The current running context of the application * @param moduleHash The hash to use for module look up * @return The db stored solution key value for the moduleHash submited *///from w w w . j av a2 s .c o m public static String getModuleResultFromHash(String ApplicationRoot, String moduleHash) { log.debug("*** Getter.getModuleResultFromHash ***"); String result = new String(); Connection conn = Database.getCoreConnection(ApplicationRoot); try { log.debug("hash '" + moduleHash + "'"); CallableStatement callstmt = conn.prepareCall("call moduleGetResultFromHash(?)"); log.debug("Gathering moduleGetResultFromHash ResultSet"); callstmt.setString(1, moduleHash); ResultSet resultSet = callstmt.executeQuery(); log.debug("Opening Result Set from moduleGetResultFromHash"); resultSet.next(); result = resultSet.getString(1); } catch (SQLException e) { log.error("Could not execute query: " + e.toString()); result = null; } Database.closeConnection(conn); log.debug("*** END getModuleResultFromHash ***"); return result; }
From source file:dbProcs.Getter.java
/** * Used to return a module cheat sheet//ww w.j a v a 2 s .c o m * @param ApplicationRoot The current running context of the application * @param moduleId The identifier of the module to return the cheat sheet for * @param lang The Locale the user has enabled * @return String[] containing {ModuleName, CheatSheetSolution} */ public static String[] getModuleSolution(String ApplicationRoot, String moduleId, Locale lang) { log.debug("*** Getter.getModuleSolution ***"); String[] result = new String[2]; Connection conn = Database.getCoreConnection(ApplicationRoot); //Getting Translations ResourceBundle bundle = ResourceBundle.getBundle("i18n.cheatsheets.solutions", lang); try { CallableStatement callstmt = conn.prepareCall("call cheatSheetGetSolution(?)"); log.debug("Gathering cheatSheetGetSolution ResultSet"); callstmt.setString(1, moduleId); ResultSet resultSet = callstmt.executeQuery(); log.debug("Opening Result Set from cheatSheetGetSolution"); resultSet.next(); result[0] = resultSet.getString(1); result[1] = bundle.getString(resultSet.getString(2)); } catch (SQLException e) { log.error("Could not execute query: " + e.toString()); result = null; } Database.closeConnection(conn); log.debug("*** END getModuleSolution ***"); return result; }
From source file:dbProcs.Getter.java
/** * This method is used to gather users according by class. Thanks to MySQL syntax, where class = null will return nothing, is null must be used. * <br/>is 'validClass' will Error, = 'validclass' must be used.<br/> * So there are two procedures this method calls. One that handles null classes, one that does not * @param ClassId Identifier of class/* www . java 2s . c om*/ * @param ApplicationRoot The current running context of the application * @return ResultSet that contains users for the selected class in the formate {userId, userName, userAddress} */ public static ResultSet getPlayersByClass(String ApplicationRoot, String classId) { ResultSet result = null; log.debug("*** Getter.getPlayersByClass (Single Class) ***"); log.debug("classId: '" + classId + "'"); Connection conn = Database.getCoreConnection(ApplicationRoot); try { CallableStatement callstmt = null; if (classId != null) { log.debug("Gathering playersByClass ResultSet"); callstmt = conn.prepareCall("call playersByClass(?)"); callstmt.setString(1, classId); log.debug("Returning Result Set from playersByClass"); } else { log.debug("Gathering playersWithoutClass ResultSet"); callstmt = conn.prepareCall("call playersWithoutClass()"); log.debug("Returning Result Set from playersByClass"); } ResultSet resultSet = callstmt.executeQuery(); result = resultSet; resultSet.next(); } catch (SQLException e) { log.error("Could not execute query: " + e.toString()); result = null; } log.debug("*** END getPlayersByClass"); return result; }
From source file:dbProcs.Getter.java
/** * @param ApplicationRoot The current running context of the application * @param userName The username of the user * @return The class id of the submitted user name */// w w w . jav a 2s . c om public static String getUserClassFromName(String ApplicationRoot, String userName) { log.debug("*** Getter.getUserClass ***"); String result = new String(); Connection conn = Database.getCoreConnection(ApplicationRoot); try { CallableStatement callstmt = conn.prepareCall("call userClassId(?)"); log.debug("Gathering userClassId ResultSet"); callstmt.setString(1, userName); ResultSet resultSet = callstmt.executeQuery(); log.debug("Opening Result Set from userClassId"); resultSet.next(); result = resultSet.getString(1); log.debug("Found " + result); } catch (SQLException e) { log.error("Could not execute userClassId: " + e.toString()); result = new String(); } Database.closeConnection(conn); log.debug("*** END getUserClass ***"); return result; }
From source file:dbProcs.Getter.java
/** * Used to gather all module information for internal functionality. This method is used in creating View's or in control class operations * @param ApplicationRoot The current runing context of the application * @return An ArrayList of String arrays that contain the module identifier, module name, module type and module category of each module in the core database. *//*from w ww . j a va2 s . c o m*/ public static ArrayList<String[]> getAllModuleInfo(String ApplicationRoot) { log.debug("*** Getter.getAllModuleInfo ***"); ArrayList<String[]> modules = new ArrayList<String[]>(); Connection conn = Database.getCoreConnection(ApplicationRoot); try { CallableStatement callstmt = conn.prepareCall("call moduleGetAll()"); log.debug("Gathering moduleGetAll ResultSet"); ResultSet resultSet = callstmt.executeQuery(); log.debug("Opening Result Set from moduleGetAll"); int i = 0; while (resultSet.next()) { String[] result = new String[4]; i++; result[0] = resultSet.getString(1); //moduleId result[1] = resultSet.getString(2); //moduleName result[2] = resultSet.getString(3); //moduleType result[3] = resultSet.getString(4); //mdouleCategory modules.add(result); } log.debug("Returning Array list with " + i + " entries."); } catch (SQLException e) { log.error("Could not execute query: " + e.toString()); } Database.closeConnection(conn); log.debug("*** END getAllModuleInfo ***"); return modules; }
From source file:dbProcs.Getter.java
/** * @param applicationRoot The current running context of the application. * @param moduleId The identifier of a module * @return The hash of the module specified *//*w ww .ja v a 2 s .co m*/ public static String getModuleHash(String applicationRoot, String moduleId) { log.debug("*** Getter.getModuleHash ***"); String result = new String(); Connection conn = Database.getCoreConnection(applicationRoot); try { CallableStatement callstmt = conn.prepareCall("call moduleGetHashById(?)"); log.debug("Gathering moduleGetHash ResultSet"); callstmt.setString(1, moduleId); ResultSet resultSet = callstmt.executeQuery(); log.debug("Opening Result Set from moduleGetHash"); resultSet.next(); result = resultSet.getString(1); } catch (SQLException e) { log.error("Could not execute moduleGetHash: " + e.toString()); result = null; } Database.closeConnection(conn); log.debug("*** END getModuleHash ***"); return result; }