<%@ page language="java" import="java.util.*" pageEncoding="GBK"
contentType="text/html;charset=gbk"
%>
<%@ page import="java.sql.*"%>
<%
int id = Integer.parseInt(request.getParameter("id"));
int rootId = Integer.parseInt(request.getParameter("rootid"));
String title = request.getParameter("title");
String cont = request.getParameter("cont"); Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost/bbs?user=root&password=root";
Connection conn = DriverManager.getConnection(url);
conn.setAutoCommit(false); String sql = "insert into article values (null,?,?,?,?,now(),0";
PrepareStatement pstmt;
pstmt = conn.prepareStatement(sql);
Statement stmt = conn.createStatement(); pstmt.setInt(1, id);
pstmt.setInt(2, rootId);
pstmt.setString(3, title);
pstmt.setString(4, cont);
pstmt.executeUpdate(); stmt.executeUpdate("update article set isleaf = 1 where id = "+ id);
conn.commit();
conn.setAutoCommit(true);
stmt.close();
pstmt.close();
conn.close();
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'ReplyOK.jsp' starting page</title>
</head>
<body>
<font color="red" size="7">OK</font>
</body>
</html>
这是源码 问题我再贴
contentType="text/html;charset=gbk"
%>
<%@ page import="java.sql.*"%>
<%
int id = Integer.parseInt(request.getParameter("id"));
int rootId = Integer.parseInt(request.getParameter("rootid"));
String title = request.getParameter("title");
String cont = request.getParameter("cont"); Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost/bbs?user=root&password=root";
Connection conn = DriverManager.getConnection(url);
conn.setAutoCommit(false); String sql = "insert into article values (null,?,?,?,?,now(),0";
PrepareStatement pstmt;
pstmt = conn.prepareStatement(sql);
Statement stmt = conn.createStatement(); pstmt.setInt(1, id);
pstmt.setInt(2, rootId);
pstmt.setString(3, title);
pstmt.setString(4, cont);
pstmt.executeUpdate(); stmt.executeUpdate("update article set isleaf = 1 where id = "+ id);
conn.commit();
conn.setAutoCommit(true);
stmt.close();
pstmt.close();
conn.close();
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'ReplyOK.jsp' starting page</title>
</head>
<body>
<font color="red" size="7">OK</font>
</body>
</html>
这是源码 问题我再贴
解决方案 »
- 基于solidworks的一级斜齿
- 求一个 用JAVA写的 私有通信协议
- web项目 超级管理员密码应该放在哪里
- 小弟初来乍到,跪求一份j2ee的中文版的APi
- ssh配置问题
- webservices如何通过代码服务器通讯数据 急等!!!
- 将XML文件返回给客户端的疑惑
- 求职--有关java的工作
- 关于Jboss4.0.0中自带数据库HyperSonic的问题
- ***在线等***用j2ee的deploytool部署出下面错误怎么回事?
- 急!!一个关于sendRedirect("/text.html?msg="+java.net.URLEncoder.encode("中国人"))的问题
- No such operation 'getRandom'
PrepareStatement cannot be resolved to a type
15: conn.setAutoCommit(false);
16:
17: String sql = "insert into article values (null,?,?,?,?,now(),0";
18: PrepareStatement pstmt;
19: pstmt = conn.prepareStatement(sql);
20: Statement stmt = conn.createStatement();
21:
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:439)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:349)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:327)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:314)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:592)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:326)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.32 logs.
--------------------------------------------------------------------------------Apache Tomcat/6.0.32
PrepareStatement pstmt;
这个类型是不存在的吧。
java.sql.PreparedStatement