<%@ page contentType="text/html;charset=gb2312"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312">
<title>教学考勤系统</title>
</head>
<body>
<center>
<%@ page language="java" import="java.sql.*"%>
<jsp:useBean id="userin" scope="page" class="DataBase.login"/>
<%
userin.opencon("teacher","sa","831010001");
String user=request.getParameter("userID");
String passwd=request.getParameter("password");
String sql="selece * from teacher where name='"+user+"'";
ResultSet rs=userin.executeQuery(sql);
if(rs.next())
{rs.close();
%>
<jsp:forward page="error.htm"/>
<%}
else
{
<jsp:forward page="success.jsp"/>
%>
<body> <%}%>
</body>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312">
<title>教学考勤系统</title>
</head>
<body>
<center>
<%@ page language="java" import="java.sql.*"%>
<jsp:useBean id="userin" scope="page" class="DataBase.login"/>
<%
userin.opencon("teacher","sa","831010001");
String user=request.getParameter("userID");
String passwd=request.getParameter("password");
String sql="selece * from teacher where name='"+user+"'";
ResultSet rs=userin.executeQuery(sql);
if(rs.next())
{rs.close();
%>
<jsp:forward page="error.htm"/>
<%}
else
{
<jsp:forward page="success.jsp"/>
%>
<body> <%}%>
</body>
</body>
</html>
解决方案 »
- java socket传多个文件的疑问?望解答
- [求助]"每个 Class 对象都包含一个对定义它的 ClassLoader 的引用。"这句话,谁能写个程序,让我理解一下?
- 问一个关于Java 正则表达式的问题,高手帮忙啊。
- 请问Spring是做什么的啊
- 请教问题!!
- 如何读取binary data?是用以存储扫描图像的binary image data
- 这个例子如何达到同步??!
- 菜鸟求救
- 我问,,JAVE 现在最流行用什么工具开发(全称),,一般在什么平台上工作。。谢谢。。
- java中的路径的问题?
- 求图像处理中的canny边缘检测算法的源程序(高分--全部家底求救)
- 争取在5.1前穿上4条裤衩,虽然可用分不多,但还是要散点分结识几个朋友.
Class.forName("oracle.jdbc.driver.OracleDriver");
connection _conn = DriverManager.getConnection(url, uid, pwd);
之类的驱动写了没有
<%@ page contentType="text/html;charset=GB2312"%>
<%@ page import="java.sql.*"%>
<html>
<head>
<title>
</title>
</head>
<body>
<%
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
out.println("连接成功");
}
catch(Exception e){out.println("连接不成功");}
try{
Connection con=DriverManager.getConnection("jdbc:odbc:user","","");
out.println("数据库连接成功");
}catch(Exception e){out.println("URL错误");}
try{
Statement state=con.createStatement();
out.println("陈述成功");
}catch(Exception e){out.println("陈述问题");}
%>
</body>
</html>
上述是调用过程,但在运行时怎么出错呢,出错信息如下:
org.apache.jasper.JasperException: Unable to compile class for JSPAn error occurred at line: 9 in the jsp file: /2.jspGenerated servlet error:
[javac] Compiling 1 source fileD:\Tomcat\work\Catalina\localhost\test\org\apache\jsp\_2_jsp.java:53: cannot resolve symbol
symbol : variable con
location: class org.apache.jsp._2_jsp
Statement state=con.createStatement();
^
1 error
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:127)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:351)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:415)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:458)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:552)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:291)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)请大家给点建议。
Connection con=DriverManager.getConnection("jdbc:odbc:user","","");
out.println("数据库连接成功");
}catch(Exception e){out.println("URL错误");}
try{
Statement state=con.createStatement();==========================
con变量出了作用域(只在try{}中有效)Connection con=null;
try{
con=DriverManager.getConnection("jdbc:odbc:user","","");
out.println("数据库连接成功");
}catch(Exception e){out.println("URL错误");}
try{
Statement state=con.createStatement();