高手进 jsp问题
luru.jsp文件错误提示Anerroroccurredatline:47inthejspfile:/jsp/jsp/jsp/luru.jspstmtcannotber...
luru.jsp文件错误提示
An error occurred at line: 47 in the jsp file: /jsp/jsp/jsp/luru.jsp
stmt cannot be resolved
44: String bh=request.getParameter ("bh");
45:
46: String ExcuteSQL="Insert into CAR_REC ( zssj,zsdd,cllx,cpxh,clhp,csys,sjfs,sjry,bz,bh )values('"+zssj+"','"+zsdd+"','"+cllx+"','"+cpxh+"','"+clhp+"','"+csys+"','"+sjfs+"','"+sjry+"','"+bz+"','"+bh+"')";
47: ResultSet rs=stmt.executeQuery(ExcuteSQL);
48:
luru.jsp 包含 conn.jsp
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<%@ page language="java"%>
<%@ page import="java.sql.*"%>
<%@ include file="rili.jsp" %>
<%@ include file="conn.jsp" %>
<%@ page trimDirectiveWhitespaces="true" %>
<%@ page import="java.io.*"%>
<%@ page import="java.util.*"%>
conn.jsp 文件为
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<%@ page language="java"%>
<%@ page import="java.sql.*"%>
<%
// ******* 数据库连接代码 开始 *****
//异常处理语句
try
{
String spath = "data.mdb"; //Access 数据库路径
String dbpath = application.getRealPath(spath); //转化成物理路径
String dbname = ""; //Acvess 数据库用户名,没有则为空
String user = ""; //Access 数据库密码,没有则为空
//数据库连接字符串
String url ="jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ="+dbpath;
//加载驱动程序
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//建立连接
Connection conn= DriverManager.getConnection(url);
//创建语句对象
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
// **** 数据库连接代码 结束 ******
%>
又出来了个这个
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 593 in the generated java file
Syntax error, insert "Finally" to complete TryStatement
An error occurred at line: 594 in the generated java file
Syntax error, insert "}" to complete ClassBody
我也没 593行啊 展开
An error occurred at line: 47 in the jsp file: /jsp/jsp/jsp/luru.jsp
stmt cannot be resolved
44: String bh=request.getParameter ("bh");
45:
46: String ExcuteSQL="Insert into CAR_REC ( zssj,zsdd,cllx,cpxh,clhp,csys,sjfs,sjry,bz,bh )values('"+zssj+"','"+zsdd+"','"+cllx+"','"+cpxh+"','"+clhp+"','"+csys+"','"+sjfs+"','"+sjry+"','"+bz+"','"+bh+"')";
47: ResultSet rs=stmt.executeQuery(ExcuteSQL);
48:
luru.jsp 包含 conn.jsp
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<%@ page language="java"%>
<%@ page import="java.sql.*"%>
<%@ include file="rili.jsp" %>
<%@ include file="conn.jsp" %>
<%@ page trimDirectiveWhitespaces="true" %>
<%@ page import="java.io.*"%>
<%@ page import="java.util.*"%>
conn.jsp 文件为
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<%@ page language="java"%>
<%@ page import="java.sql.*"%>
<%
// ******* 数据库连接代码 开始 *****
//异常处理语句
try
{
String spath = "data.mdb"; //Access 数据库路径
String dbpath = application.getRealPath(spath); //转化成物理路径
String dbname = ""; //Acvess 数据库用户名,没有则为空
String user = ""; //Access 数据库密码,没有则为空
//数据库连接字符串
String url ="jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ="+dbpath;
//加载驱动程序
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//建立连接
Connection conn= DriverManager.getConnection(url);
//创建语句对象
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
// **** 数据库连接代码 结束 ******
%>
又出来了个这个
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 593 in the generated java file
Syntax error, insert "Finally" to complete TryStatement
An error occurred at line: 594 in the generated java file
Syntax error, insert "}" to complete ClassBody
我也没 593行啊 展开
2个回答
展开全部
错误提示:An error occurred at line: 47 in the jsp file: /jsp/jsp/jsp/luru.jsp
stmt cannot be resolved
说在第47行,对象stmt没有找到。
原因是你的连接是在一个文件里写的。并且被try块包起来了。
所以出了try块,定义的stmt就找不到了。
可以先在前面定义访问数据库使用的对象,如下
<%
// ******* 数据库连接代码 开始 *****
Connection conn=null;
Statement stmt=null;
//异常处理语句
try
{
String spath = "data.mdb"; //Access 数据库路径
String dbpath = application.getRealPath(spath); //转化成物理路径
String dbname = ""; //Acvess 数据库用户名,没有则为空
String user = ""; //Access 数据库密码,没有则为空
//数据库连接字符串
String url ="jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ="+dbpath;
//加载驱动程序
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//建立连接
conn= DriverManager.getConnection(url);
//创建语句对象
stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
// **** 数据库连接代码 结束 ******
%>
stmt cannot be resolved
说在第47行,对象stmt没有找到。
原因是你的连接是在一个文件里写的。并且被try块包起来了。
所以出了try块,定义的stmt就找不到了。
可以先在前面定义访问数据库使用的对象,如下
<%
// ******* 数据库连接代码 开始 *****
Connection conn=null;
Statement stmt=null;
//异常处理语句
try
{
String spath = "data.mdb"; //Access 数据库路径
String dbpath = application.getRealPath(spath); //转化成物理路径
String dbname = ""; //Acvess 数据库用户名,没有则为空
String user = ""; //Access 数据库密码,没有则为空
//数据库连接字符串
String url ="jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ="+dbpath;
//加载驱动程序
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//建立连接
conn= DriverManager.getConnection(url);
//创建语句对象
stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
// **** 数据库连接代码 结束 ******
%>
追问
又出来了个这个
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 593 in the generated java file
Syntax error, insert "Finally" to complete TryStatement
An error occurred at line: 594 in the generated java file
Syntax error, insert "}" to complete ClassBody
我也没 593行啊
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询