public static void main(String[] args) {
    // The newInstance() call is a work around for some
    // broken Java implementations

    try {
      Class.forName("com.mysql.jdbc.Driver").newInstance();
    } catch (InstantiationException e) {
      e.printStackTrace();
    } catch (IllegalAccessException e) {
      e.printStackTrace();
    } catch (ClassNotFoundException e) {
      e.printStackTrace();
    }
    new DbConnector();
    User u = new User();
    u.setUserName("user1");
    u.setPassword("user1pwd");
    getUser(u);
    Building b = u.getBld();
    drawpoly dp = new drawpoly(b);
    getBldSubAreas(dp);
  }
 /**
  * Function to get the user information based to userName and password provided and validate
  *
  * @param user
  */
 public static void getUser(User user) {
   try {
     conn =
         DriverManager.getConnection(
             "jdbc:mysql://localhost/sosecurity?" + "user=ssuser&password=sspwd");
     Statement stmt = null;
     ResultSet rs = null;
     try {
       stmt = (Statement) conn.createStatement();
       String getUser =
           "******""
               + user.getUserName()
               + "\" and s.userID = b.userID and s.password = \""
               + user.getPassword()
               + "\"";
       System.out.println(getUser);
       try {
         rs = stmt.executeQuery(getUser);
         try {
           while (rs.next()) {
             String imagePath = null;
             int bldID = 0;
             int numColumns = rs.getMetaData().getColumnCount();
             for (int i = 1; i <= numColumns; i++) {
               user.setUserID(rs.getLong("userID"));
               user.setUserName(rs.getString("userName"));
               user.setPassword(rs.getString("password"));
               user.setPhoneNumber(rs.getString("phoneNumber"));
               user.setEmail(rs.getString("email"));
               imagePath = rs.getString("imagePath");
               bldID = rs.getInt("bldID");
             }
             Building b = new Building(bldID, imagePath);
             user.setBldID(b);
             System.out.println(user.toString());
             return;
           }
         } finally {
           try {
             rs.close();
           } catch (Throwable ignore) {
             /*
              * Propagate the original exception instead of this
              * one that you may want just logged
              */
             ignore.printStackTrace();
           }
         }
       } finally {
         try {
           stmt.close();
         } catch (Throwable ignore) {
           /*
            * Propagate the original exception instead of this one
            * that you may want just logged
            */
           ignore.printStackTrace();
         }
       }
     } finally {
       // It's important to close the connection when you are done with
       // it
       try {
         conn.close();
       } catch (Throwable ignore) {
         /*
          * Propagate the original exception instead of this one that
          * you may want just logged
          */
         ignore.printStackTrace();
       }
     }
   } catch (SQLException ex) {
     // handle any errors
     System.out.println("SQLException: " + ex.getMessage());
     System.out.println("SQLState: " + ex.getSQLState());
     System.out.println("VendorError: " + ex.getErrorCode());
   }
   return;
 }