conn = TransactionManager.getConnection();
pstmt = conn.prepareStatement(sb.toString());
pstmt.setString(1,newLoginName);
pstmt.setString(2,StringUtil.hash(newPassword));
pstmt.setString(3,newName);
pstmt.setString(4,newEmalAddress);
pstmt.setString(5,StringUtil.dateToMillis(new Date()));
pstmt.setString(6,oldLoginName);
pstmt.execute();
pstmt = conn.prepareStatement(sb.toString());
pstmt.setString(1,newLoginName);
pstmt.setString(2,StringUtil.hash(newPassword));
pstmt.setString(3,newName);
pstmt.setString(4,newEmalAddress);
pstmt.setString(5,StringUtil.dateToMillis(new Date()));
pstmt.setString(6,oldLoginName);
pstmt.execute();
pstmt = conn.prepareStatement(sb.toString());建立prepareStatement
pstmt.setString(1,newLoginName);给SQL语句赋值
pstmt.setString(2,StringUtil.hash(newPassword));
pstmt.setString(3,newName);
pstmt.setString(4,newEmalAddress);
pstmt.setString(5,StringUtil.dateToMillis(new Date()));
pstmt.setString(6,oldLoginName);
pstmt.execute(); 执行SQL
StringBuffer sb = new StringBuffer();
sb.append("UPDATE Lex_User ");
sb.append(" SET change_pass_time = "+d);
sb.append(" WHERE login_name = '"+loginname+"'");
Connection conn = null;
PreparedStatement pstmt = null;
System.out.println(sb.toString());
System.out.println(d);
System.out.println(loginname);
try {
conn = TransactionManager.getConnection();
pstmt = conn.prepareStatement(sb.toString());
conn.commit();
} catch (SQLException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
throw new SystemException("Database operation error!");
}
StringBuffer sb = new StringBuffer();
sb.append("UPDATE Lex_User ");
sb.append(" SET change_pass_time = "+d);
sb.append(" WHERE login_name = '"+loginname+"'");
Connection conn = null;
PreparedStatement pstmt = null;
try {
conn = TransactionManager.getConnection();
pstmt = conn.prepareStatement(sb.toString());
conn.commit();
pstmt.execute();
} catch (SQLException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
throw new SystemException("Database operation error!");
}
conn = TransactionManager.getConnection();
pstmt = conn.prepareStatement(sb.toString());
pstmt.execute();conn.commit();
比如:sql = "select * from xxx where id = ?";
pstmt.setString(1,xx);//用值替换问号
ResultSet rs = pstmt.execute();//执行
好象是这么个意思,好久不用预编译了
看看jsp应用开发详解