sql server2000 jdbc连接问题~大家帮忙!
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: /web/flysky/regist.jsp(9,0) The value for the useBean class attribute opendb.opendb is invalid.
这个是怎么回事啊?
下面是opendb.java
和注册页面regist.jsp
我放在了Tomcat的Tomcat 6.0\webapps\ROOT\
regist.jsp
<%@ page
language= "java "
contentType= "text/html; charset=UTF-8 "
pageEncoding= "UTF-8 "
import = "java.util.* "
import = "java.sql.* "
%>
<META http-equiv= "Content-Type " content= "text/html; charset=UTF-8 ">
<jsp:useBean id= "RegisterBean " scope= "page " class= "opendb.opendb " />
<%
String id=request.getParameter( "id ");
String password=request.getParameter( "password ");
if ((id==null)||(password==null))
{
%>
<p> 用户名和密码不能为空! </p>
<input type= "button " value= "返回修改 " onclick= "histroy.back() ">
<%
}
else
{
String sql= "select * from user where id= ' "+id+ " ' ";
System.out.println( "sql::: "+sql);
ResultSet rs=RegisterBean.executeQuery(sql);
if (rs.next())
{
rs.close();
session.putValue( "register_message ", "duplicate name foung! ");
%>
<script language=javascript>
window.location= "info.jsp?str=用户 <%=id%> 已经存在 "
</script>
<%
}
else
{
rs.close();
%>
<form method= "post " action= "register2.jsp ">
<input type= "hidden " name= "id " value= " <%=id%> ">
<input type= "hidden " name= "password " value= " <%=password%> ">
请检查您的注册信息 <br> <br>
<table width= "60% " border= "1 ">
<tr>
<td>
账号:
</td>
<td>
<%=id%>
</td>
</tr>
<tr>
<td>
密码:
</td>
<td>
<%=password%>
</td>
</tr>
</table>
<br>
<input type= "submit " value= "提交注册 ">
<input type= "reset " value= "返回修改 " onclick= "histroy.back() ">
</form>
<%
}
%>
</center>
<%
}
%>
</body>
</html>
opendb.java
package opendb; //定义包opendb
import java.sql.*; //引入java.sql.*
import javax.sql.*;
import javax.naming.*;
public class opendb
{
Connection conn=null;
ResultSet rs=null;
//定义打开数据库连接的函数
public opendb()
{
try
{
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver ");
conn = DriverManager.getConnection( "jdbc:odbc:flysky ", "sa ", "850811 ");
}
catch(Exception exc)
{
exc.printStackTrace();
}
}
//定义执行sql语句的函数
public ResultSet executeQuery(String sql)
{
rs=null;
try
{
Statement stmt=conn.createStatement();
rs=stmt.executeQuery(sql);
}
catch (SQLException ex)
{
System.err.println( "aq.executeQuery: "+ex.getMessage());
}
return rs;//返回sql语句的执行结果
}
}
[解决办法]
org.apache.jasper.JasperException: /web/flysky/regist.jsp(9,0) The value for the useBean class attribute opendb.opendb is invalid.
<jsp:useBean id= "RegisterBean " scope= "page " class= "opendb.opendb " /> 这个有问题
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver ");你确定有这个驱动吗?
如果是连接sqlserver最好用 ms的驱动或JSQLConnect
最好看看opendb的抱的什么错 看看打印结果
还有你的类名第一个字母最好写
[解决办法]
Class.forName( "com.microsoft.jdbc.sqlserver.SQLServerDriver ");
1 到www.microsoft.com上下载 "Microsoft SQL Server 2000 Driver for JDBC "并安装
2 安装后,在安装的目录中有三个jar文件包
.\lib\msbase.jar
.\lib\msutil.jar
.\lib\mssqlserver.jar
配置上。
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.myexception.cn/java-web/317.html