[Microsoft][ODBC SQL Server Driver]无效的描述符索引
<%@pagelanguage="java"contentType="text/html;charset=gbk"pageEncoding="gbk"%><%@pagei...
<%@ page language="java" contentType="text/html; charset=gbk"
pageEncoding="gbk"%>
<%@page import="java.sql.*"%>
<%!
String str = "";
private void tree(Connection conn, int id, int level) {
Statement stmt = null;
ResultSet rs = null;
String preStr = "";
for (int i = 0; i < level; i++) {
preStr += "----";
}
try {
stmt = conn.createStatement();
String sql = "select * from article where pid =" + id;
rs = stmt.executeQuery(sql);
while (rs.next()) {
str += "<tr><td>" + rs.getInt("id") + "</td></tr>" + preStr
+ rs.getString("cont") + "</td></tr>";
if (rs.getInt("isleaf") != 0) {
tree(conn, rs.getInt("id"), level + 1);
}
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
if (rs != null) {
rs.close();
rs = null;
}
if (stmt != null) {
stmt.close();
stmt = null;
}
if (conn != null) {
conn.close();
conn = null;
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
%>
<%
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn = DriverManager.getConnection(
"jdbc:odbc:mayachong", "yachong", "111");
Statement stmt = conn.createStatement();
ResultSet rs = stmt
.executeQuery("select * from article where pid =0");
while (rs.next()) {
str += "<tr><td>" + rs.getInt("id") + "</td><td>"
+ rs.getString("cont") + "</td></tr>";
if (rs.getInt("isleaf") != 0) {
tree(conn,rs.getInt("id"),1);
}
}
rs.close();
stmt.close();
conn.close();
%>
<!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=gbk">
<title>Insert title here</title>
</head>
<body>
<table border="1">
<%= str %>
</table>
</body>
org.apache.jasper.JasperException: Exception in JSP: /ShowArticleTree.jsp:70
67: str += "<tr><td>" + rs.getInt("id") + "</td><td>"
68: + rs.getString("cont") + "</td></tr>";
69: if (rs.getInt("isleaf") != 0) {
70: tree(conn,rs.getInt("id"),1);
71: }
72: }
73:
java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]无效的描述符索引
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6957)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7114)
at sun.jdbc.odbc.JdbcOdbc.SQLGetDataInteger(JdbcOdbc.java:3811)
at sun.jdbc.odbc.JdbcOdbcResultSet.getDataInteger(JdbcOdbcResultSet.java:5638)
at sun.jdbc.odbc.JdbcOdbcResultSet.getInt(JdbcOdbcResultSet.java:583)
at sun.jdbc.odbc.JdbcOdbcResultSet.getInt(JdbcOdbcResultSet.java:601)
at org.apache.jsp.ShowArticleTree_jsp._jspService 展开
pageEncoding="gbk"%>
<%@page import="java.sql.*"%>
<%!
String str = "";
private void tree(Connection conn, int id, int level) {
Statement stmt = null;
ResultSet rs = null;
String preStr = "";
for (int i = 0; i < level; i++) {
preStr += "----";
}
try {
stmt = conn.createStatement();
String sql = "select * from article where pid =" + id;
rs = stmt.executeQuery(sql);
while (rs.next()) {
str += "<tr><td>" + rs.getInt("id") + "</td></tr>" + preStr
+ rs.getString("cont") + "</td></tr>";
if (rs.getInt("isleaf") != 0) {
tree(conn, rs.getInt("id"), level + 1);
}
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
if (rs != null) {
rs.close();
rs = null;
}
if (stmt != null) {
stmt.close();
stmt = null;
}
if (conn != null) {
conn.close();
conn = null;
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
%>
<%
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn = DriverManager.getConnection(
"jdbc:odbc:mayachong", "yachong", "111");
Statement stmt = conn.createStatement();
ResultSet rs = stmt
.executeQuery("select * from article where pid =0");
while (rs.next()) {
str += "<tr><td>" + rs.getInt("id") + "</td><td>"
+ rs.getString("cont") + "</td></tr>";
if (rs.getInt("isleaf") != 0) {
tree(conn,rs.getInt("id"),1);
}
}
rs.close();
stmt.close();
conn.close();
%>
<!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=gbk">
<title>Insert title here</title>
</head>
<body>
<table border="1">
<%= str %>
</table>
</body>
org.apache.jasper.JasperException: Exception in JSP: /ShowArticleTree.jsp:70
67: str += "<tr><td>" + rs.getInt("id") + "</td><td>"
68: + rs.getString("cont") + "</td></tr>";
69: if (rs.getInt("isleaf") != 0) {
70: tree(conn,rs.getInt("id"),1);
71: }
72: }
73:
java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]无效的描述符索引
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6957)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7114)
at sun.jdbc.odbc.JdbcOdbc.SQLGetDataInteger(JdbcOdbc.java:3811)
at sun.jdbc.odbc.JdbcOdbcResultSet.getDataInteger(JdbcOdbcResultSet.java:5638)
at sun.jdbc.odbc.JdbcOdbcResultSet.getInt(JdbcOdbcResultSet.java:583)
at sun.jdbc.odbc.JdbcOdbcResultSet.getInt(JdbcOdbcResultSet.java:601)
at org.apache.jsp.ShowArticleTree_jsp._jspService 展开
3个回答
2011-05-05
展开全部
可以把你的表结构发出来看看
另外,虚机团上产品团购,超级便宜
另外,虚机团上产品团购,超级便宜
TableDI
2024-07-18 广告
2024-07-18 广告
在上海悉息信息科技有限公司,我们深知Excel在数据处理中的重要作用。在Excel中引用不同工作表(sheet)的数据是常见的操作,这有助于整合和分析跨多个工作表的信息。通过在工作表名称前加上感叹号“!”,您可以轻松地引用其他工作表中的数据...
点击进入详情页
本回答由TableDI提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询