首先附上最刚开始的代码,功能是向数据库中插入数据,数据库中的属性如下:
<%
String action = request.getParameter("action"); //表单中提交过来的数据。
if(action != null && action.equals("submit")) { //如果进行提交,则进行数据插入
String title = request.getParameter("title");
String content = request.getParameter("content");
Class.forName("com.mysql.jdbc.Driver"); //加载及注册jdbc驱动
String url = "jdbc:mysql://localhost:3306/bbs?user=root&password=199288";
Connection con = DriverManager.getConnection(url);
con.setAutoCommit(false); //设置不自动提交
String psql = "insert into article values (null, 0, ?, ?, ?, now(), 0)";
PreparedStatement pstmt = con.prepareStatement(psql, Statement.RETURN_GENERATED_KEYS);
pstmt.setInt(1, -1);
pstmt.setString(