Code example for SQLException

Methods: getMessagegetErrorCodegetSQLState

0
            if (rs.first() == true) {
                Count = rs.getInt("TroopCount");
            } 
        }catch (SQLException e) {
            System.out.println("Retrival Error!");
            System.out.println("SQL Error: " + e.getMessage());
            System.out.println("SQL State: " + e.getSQLState());
            System.out.println("VendorError: " + e.getErrorCode());
        }finally{ 
            if (stmt != null) { stmt.close(); }
        } 
        return Count;
    } 
    public static int getCivilCount(String Nation) throws SQLException {
        int Count = 0;
        Connection con = Database.getConnection();
        Statement stmt = null;
        String query = "select * from NationInfo where Name = '" + Nation + "'";
        try { 
            stmt = con.createStatement();
Stop searching for code, let great code find you!  Add Codota to your java IDE