日期:2014-05-17 浏览次数:20892 次
String sqlNum = "update article set num=num+1 where rootid = " + id;
Statement stmt = DB.createStmt(conn);
stmt.executeUpdate(sqlNum);
String title = request.getParameter("title");
String cont = request.getParameter("cont");
String nameSign = (String) session.getAttribute("userId");
Connection conn = DB.getConn();
boolean autoCommit = conn.getAutoCommit();
conn.setAutoCommit(false);
int rootId = -1;
String sql = "insert into article values(null,?,?,?,?,now(),?,?)";
PreparedStatement pstmt = DB.prepareStmt(conn,sql,Statement.RETURN_GENERATED_KEYS);
pstmt.setInt(1, 0);
pstmt.setInt(2, rootId);
pstmt.setString(3, title);
pstmt.setString(4, cont);
pstmt.setInt(5, 0);
pstmt.setString(6,nameSign);
pstmt.executeUpdate();