请教各位高手:我写了一个简单的读取数据的 JSP程序,程序运行到和数据库建立连接语句时发生如下错误,请各位指点~

runningman525 2004-05-09 03:22:23

请教各位高手:我写了一个简单的读取数据的 JSP程序,程序运行到和数据库建立连接语句时发生如下错误,请各位指点~

我的数据源配的应该没问题

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: [Microsoft][ODBC SQL Server Driver][SQL Server]?? '(null)' ???????: ???? SQL Server ??????
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:867)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:800)
org.apache.jsp.Next1_jsp._jspService(Next1_jsp.java:76)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
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)


root cause

java.sql.SQLException: [Microsoft][ODBC SQL Server Driver][SQL Server]?? '(null)' ???????: ???? SQL Server ??????
sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6879)
sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7036)
sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(JdbcOdbc.java:3028)
sun.jdbc.odbc.JdbcOdbcConnection.initialize(JdbcOdbcConnection.java:323)
sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:174)
java.sql.DriverManager.getConnection(DriverManager.java:512)
java.sql.DriverManager.getConnection(DriverManager.java:193)
org.apache.jsp.Next1_jsp._jspService(Next1_jsp.java:61)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
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)


note The full stack trace of the root cause is available in the Tomcat logs.
...全文
7 点赞 收藏 2
写回复
2 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
runningman525 2004-05-09
我的“用户DNS” 配置的没错儿 已经配置两回了

这是完整的程序:

<%@ page contentType="text/html; charset=GB2312" %>
<%@ page import="java.sql.*" %>
<%@ page language="java" %>
<HTML>
<HEAD>
<TITLE>顺序取得数据</TITLE>
</HEAD>
<BODY>
<CENTER>
<FONT SIZE = 5 COLOR = blue>顺序取得数据</FONT>
</CENTER>
<BR>
<HR>
<BR>
<CENTER>
<%
out.println("ddddd");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); //载入驱动程序类别
Connection con = DriverManager.getConnection("jdbc:odbc:BookDB"); //建立数据库链接
Statement stmt = con.createStatement(); //建立Statement对象
ResultSet rs; //建立ResultSet(结果集)对象
rs = stmt.executeQuery("SELECT * FROM book"); //执行SQL语句
%>
<TABLE bgcolor=pink>
<TR bgcolor=silver>
<TD><B>书籍编号</B></TD><TD><B>书 名</B></TD><TD><B>作 者</B></TD>
</TR>
<%
//利用while循环将数据表中的记录列出
while (rs.next())
{
%>
<TR bgcolor=white>
<TD><B><%= rs.getString("bookid") %></B></TD>
<TD><B><%= rs.getString("title") %></B></TD>
<TD><B><%= rs.getString("author") %></B></TD>
</TR>
<%
}
rs.close(); //关闭ResultSet对象
stmt.close(); //关闭Statement对象
con.close(); //关闭Connection对象
%>
</TABLE>
</CENTER>
</BODY>
</HTML>
回复
passwords 2004-05-09
看下的的DNS写的对不对!看着象是!
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2004-05-09 03:22
社区公告
暂无公告