一问
String sql = "select * from t2";
这是我连接数据库的sql语句
结果出现:
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]??? 't2' ???
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:862)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:795)
org.apache.jsp._9_jsp._jspService(_9_jsp.java:93)
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][SQLServer 2000 Driver for JDBC][SQLServer]??? 't2' ???
com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
com.microsoft.jdbc.sqlserver.tds.TDSRequest.processErrorToken(Unknown Source)
com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReplyToken(Unknown Source)
com.microsoft.jdbc.sqlserver.tds.TDSExecuteRequest.processReplyToken(Unknown Source)
com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReply(Unknown Source)
com.microsoft.jdbc.sqlserver.SQLServerImplStatement.getNextResultType(Unknown Source)
com.microsoft.jdbc.base.BaseStatement.commonTransitionToState(Unknown Source)
com.microsoft.jdbc.base.BaseStatement.postImplExecute(Unknown Source)
com.microsoft.jdbc.base.BaseStatement.commonExecute(Unknown Source)
com.microsoft.jdbc.base.BaseStatement.executeQueryInternal(Unknown Source)
com.microsoft.jdbc.base.BaseStatement.executeQuery(Unknown Source)
org.apache.jsp._9_jsp._jspService(_9_jsp.java:64)
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.
--------------------------------------------------------------------------------
Apache Tomcat/5.0.14
什么原因呢?!
问题点数:10、回复次数:4Top
1 楼warren04(Just Try !)回复于 2003-12-01 12:23:03 得分 1
把你的原码贴出来吧。就这样看是没错哟Top
2 楼jie015(杰)回复于 2003-12-01 12:37:22 得分 3
好像找不到数据源。Top
3 楼skyboy0720(曲终人散)回复于 2003-12-01 12:59:40 得分 0
javax.servlet.ServletException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]??? 't2' ???
我主要是想知道这句话什么意思?
为什么会 ???t2???
难道说我的表错?!我有这个表啊!
是书上一个例子
<%@ page contentType="text/html;charset=gb2312" %>
<%@ page session="true" %>
<%@ page import="java.sql.*" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>姓名</title>
</head>
<body>
<%
Class.forName( "com.microsoft.jdbc.sqlserver.SQLServerDriver" ).newInstance ( );
String url = "jdbc:microsoft:sqlserver://8760-HUA:1433;DatabaseName = test";
String user = "sa";
String password = "xiaoqiang";
Connection con = DriverManager.getConnection ( url, user, password );
Statement stmt = con.createStatement ( ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE );
String sql = "select * from t2";
ResultSet rs = stmt.executeQuery ( sql );
while ( rs.next ( ) )
{
%>
你的第一个字段内容为:<%=rs.getString ( 1 )%>
你的第二个字段内容为:<%=rs.getString ( 2 )%>
<% } %>
<% out.print ( "数据库操作成功,恭喜你" ); %>
<%
rs.close ( );
stmt.close ( );
con.close ( );
%>
</body>
</html>Top
4 楼qybao(阿宝)回复于 2003-12-01 13:24:38 得分 6
好像看不出什么问题
具体提示报错在哪一行了吗?
把
Statement stmt = con.createStatement ( ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE );
改成
Statement stmt = con.createStatement ();
试试,好像odbc连接数据库时建立Statement时createStatement()带参数是会有问题的
具体什么原因我也不知道。
Top




