示例#1
0
 @Override
 public void loginQueryImpl(Map<String, String> loginmap) {
   Connection conn = null;
   String sql = "";
   String key = "";
   String values = "";
   try {
     conn = Dbtool.getConnection();
     for (Entry<String, String> entry : loginmap.entrySet()) {
       key += entry.getKey() + ",";
       values += "'" + entry.getValue() + "'" + ",";
     }
     String k = key.substring(0, key.length() - 1);
     String v = values.substring(0, values.length() - 1);
     sql = "insert into login (" + k + ") values (" + v + ")";
     PreparedStatement pstmt = conn.prepareStatement(sql);
     pstmt.executeUpdate();
   } catch (SQLException e) {
     LogRecord.error(loginImpl.class, e);
   } finally {
     if (conn != null) {
       try {
         conn.close();
       } catch (SQLException e) {
         LogRecord.error(loginImpl.class, e);
       }
     }
   }
 }
示例#2
0
 @Override
 public void loginUpdateImpl(String lid, String state) {
   Connection conn = null;
   String sql = "";
   try {
     conn = Dbtool.getConnection();
     sql = "UPDATE login SET state = " + state + " WHERE lid = " + "'" + lid + "'";
     PreparedStatement pstmt = conn.prepareStatement(sql);
     pstmt.executeUpdate();
   } catch (SQLException e) {
     LogRecord.error(loginImpl.class, e);
   } finally {
     if (conn != null) {
       try {
         conn.close();
       } catch (SQLException e) {
         LogRecord.error(loginImpl.class, e);
       }
     }
   }
 }