我用的是SQL数据库
写了一个UserMan.java的文件内容是 package kernel;
import java.sql.*;public class UserMan{
private String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=sqldata;user=sa;password=520";
public UserMan(){
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
}
catch (Exception ex){
ex.printStackTrace();
}
}
public boolean userExist(String userID){
Connection con=null;
PreparedStatement ps=null;
ResultSet rs=null;
boolean exist=true;
try{
con=DriverManager.getConnection(url);
String selectStr="select * from userat where name=?";
ps=con.prepareStatement(selectStr);
ps.setString(1, userID);
rs=ps.executeQuery();
if (!rs.next())
exist=false;
}
catch(SQLException exc){
exc.printStackTrace();
}
finally{
if (rs!=null) try {rs.close();} catch (SQLException ignore){}
if (ps!=null) try {ps.close();} catch (SQLException ignore){}
if (con!=null) try {con.close();} catch (SQLException ignore){}
}
return exist;
}
}然后建了一个default.htm的文件做为登录提交的,代码是
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head><body>
<form name="form1" method="post" action="login.jsp">
<input name="names" type="text" id="names">
<input type="submit" name="Submit" value="提交">
</form>
</body>
</html>来了个验证login.jsp,代码是
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<jsp:useBean id="UserMan" scope="page" class="kernel.UserMan"></jsp:useBean><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head><body>
<%
String username=request.getParameter("names");
if (!UserMan.userExist(username))
{
out.print("error!!");
}
else{
out.print("ok!!!");
}
%>
</body>
</html> 出现错误 type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception javax.servlet.ServletException: kernel/UserMan (Unsupported major.minor version 49.0)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:244)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
看不明白是什么错误
写了一个UserMan.java的文件内容是 package kernel;
import java.sql.*;public class UserMan{
private String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=sqldata;user=sa;password=520";
public UserMan(){
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
}
catch (Exception ex){
ex.printStackTrace();
}
}
public boolean userExist(String userID){
Connection con=null;
PreparedStatement ps=null;
ResultSet rs=null;
boolean exist=true;
try{
con=DriverManager.getConnection(url);
String selectStr="select * from userat where name=?";
ps=con.prepareStatement(selectStr);
ps.setString(1, userID);
rs=ps.executeQuery();
if (!rs.next())
exist=false;
}
catch(SQLException exc){
exc.printStackTrace();
}
finally{
if (rs!=null) try {rs.close();} catch (SQLException ignore){}
if (ps!=null) try {ps.close();} catch (SQLException ignore){}
if (con!=null) try {con.close();} catch (SQLException ignore){}
}
return exist;
}
}然后建了一个default.htm的文件做为登录提交的,代码是
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head><body>
<form name="form1" method="post" action="login.jsp">
<input name="names" type="text" id="names">
<input type="submit" name="Submit" value="提交">
</form>
</body>
</html>来了个验证login.jsp,代码是
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<jsp:useBean id="UserMan" scope="page" class="kernel.UserMan"></jsp:useBean><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head><body>
<%
String username=request.getParameter("names");
if (!UserMan.userExist(username))
{
out.print("error!!");
}
else{
out.print("ok!!!");
}
%>
</body>
</html> 出现错误 type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception javax.servlet.ServletException: kernel/UserMan (Unsupported major.minor version 49.0)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:244)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
看不明白是什么错误
解决方案 »
- struts2自带项目struts2-mailreader
- lnux 提交表单乱码
- 关于sun.net.ftp.FtpClient
- 请大家帮忙!!!在此谢谢了.
- 有谁做过客户端文件下载的?(急)
- 如何将一个jsp页面表单中的值传到另一个jsp页面的表单中?
- 关于java.sql.SQLException,虚心求教。
- 求助 javabean的最简单调用,分现解!!!在线等
- 字段显示有问题,请教高手,急,急,急,拖了很久了,谢谢!
- esayui treegrid 刷新问题求解??????
- 【50分】过滤网页HTML标记-求方法
- 第一次用log4j,总是出现log4j:WARN File option not set for appender [A1].错误,怎么办??
参考下面文章:
http://www.blogjava.net/crazycy/archive/2006/06/03/50150.html
估计3.2必须用1.5以上吧
1.eclipse3.2默认用的是jdk1.5,我估计你没改.
2.你用的是tomcate5.0,使的jdk是j2sdk1.4.2_06,
所以错误就出来了,jdk1.4的解释不了jdk5.0编绎的类