//查询处理 public ArrayList select() { ArrayList list = new ArrayList(); PreparedStatement pstmt = null; ResultSet rset = null; String sql = " SELECT * FROM dbo.[EmployeePublic] WHERE id = ? "; try { pstmt = this.con.prepareStatement(sql); pstmt.setString(1, "a"); rset = pstmt.executeQuery(); while (rset.next()) { list.add(rset.getString("EmployeeNo")); list.add(rset.getString("EmployeeName")); } } catch (Exception e) { e.printStackTrace(); } finally { try { if (pstmt != null) { pstmt.close(); } if (rset != null) { rset.close(); } } catch (Exception e) { e.printStackTrace(); } } return list; } //增加,修改,删除处理 public boolean iudFunc() { PreparedStatement pstmt = null; boolean ret = true; String sql = " UPDATE dbo.[Organization] SET id = ? WHERE Year = ? "; try { pstmt = con.prepareStatement(sql); pstmt.setString(1, "a"); pstmt.setString(2, "b"); pstmt.execute(); } catch (Exception e) { e.printStackTrace(); ret = false; } finally { try { if (pstmt != null) { pstmt.close(); } } catch (Exception e) { e.printStackTrace(); } } return ret; }
2000年5月11日星期四
SQL增删改查处理
订阅:
博文评论 (Atom)
没有评论:
发表评论