出错了,给看一下吧:无效的描述符索引相关错误

damner 2002-05-27 11:40:52
在运行时出错了,
TOMCAT4、JDK1.4、IIS

java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]无效的描述符索引
...全文
9 点赞 收藏 7
写回复
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
Andrawu 2002-05-27
请你最好是用jsp+servlet+javaBean的模式来做,这样做会更好。
你的问题多半是sql语句有问题(包括语法、字段属性等)。
回复
Andrawu 2002-05-27
你的错误比较难找:

if (!MM_abortEdit) {
// finish the sql and execute it
Driver MM_driver = (Driver)Class.forName(MM_editDriver).newInstance();
Connection MM_connection = DriverManager.getConnection(MM_editConnection,MM_editUserName,MM_editPassword);
out.println("Sql=="+MM_editQuery.toString()) ;//输出你的SQL语句看看,有没有问题,把它放到sql分析器中执行一下。
PreparedStatement MM_editStatement = MM_connection.prepareStatement(MM_editQuery.toString());
MM_editStatement.executeUpdate();
MM_connection.close();

如果上面语句没有输出,说明错误不在这里,可能在上面,你可能用同样的方法跟踪。
回复
ephemeral 2002-05-27
我遇到过同样的问题,原因是我提交的字符串超过了在数据库中变量定义的长度,也显示javax.servlet.ServletException: [Microsoft][ODBC SQL Server Driver][SQL Server]将截断字符串或二进制数据。
应该和你定义的变量长度或输入数据有关。
回复
damner 2002-05-27
源程序对于上面的的错误,我想应该是一个原因吧, 如果解决了,我会再加分的 80

<%@ include file="Connections/Intranet_conn.jsp" %>
<%
// *** Edit Operations: declare variables

// set the form action variable
String MM_editAction = request.getRequestURI();
if (request.getQueryString() != null && request.getQueryString().length() > 0) {
MM_editAction += "?" + request.getQueryString();
}

// connection information
String MM_editDriver = null, MM_editConnection = null, MM_editUserName = null, MM_editPassword = null;

// redirect information
String MM_editRedirectUrl = null;

// query string to execute
StringBuffer MM_editQuery = null;

// boolean to abort record edit
boolean MM_abortEdit = false;

// table information
String MM_editTable = null, MM_editColumn = null, MM_recordId = null;

// form field information
String[] MM_fields = null, MM_columns = null;
%>
<%
// *** Insert Record: set variables

if (request.getParameter("MM_insert") != null && request.getParameter("MM_insert").toString().equals("form1")) {

MM_editDriver = MM_Intranet_conn_DRIVER;
MM_editConnection = MM_Intranet_conn_STRING;
MM_editUserName = MM_Intranet_conn_USERNAME;
MM_editPassword = MM_Intranet_conn_PASSWORD;
MM_editTable = "dbo.web_txb";
MM_editRedirectUrl = "addsucc.html";
String MM_fieldsStr = "name|value|sex|value|nation|value|unit|value|job|value|area_no|value|tel_no|value|mol_no|value|email|value|address|value|post_no|value";
String MM_columnsStr = "name|',none,''|sex|',none,''|nation|',none,''|unit|',none,''|job|',none,''|area_no|',none,''|tel_no|',none,''|mob_no|',none,''|email|',none,''|address|',none,''|post_no|',none,''";

// create the MM_fields and MM_columns arrays
java.util.StringTokenizer tokens = new java.util.StringTokenizer(MM_fieldsStr,"|");
MM_fields = new String[tokens.countTokens()];
for (int i=0; tokens.hasMoreTokens(); i++) MM_fields[i] = tokens.nextToken();

tokens = new java.util.StringTokenizer(MM_columnsStr,"|");
MM_columns = new String[tokens.countTokens()];
for (int i=0; tokens.hasMoreTokens(); i++) MM_columns[i] = tokens.nextToken();

// set the form values
for (int i=0; i+1 < MM_fields.length; i+=2) {
MM_fields[i+1] = ((request.getParameter(MM_fields[i])!=null)?(String)request.getParameter(MM_fields[i]):"");
}

// append the query string to the redirect URL
if (MM_editRedirectUrl.length() != 0 && request.getQueryString() != null) {
MM_editRedirectUrl += ((MM_editRedirectUrl.indexOf('?') == -1)?"?":"&") + request.getQueryString();
}
}
%>
<%
// *** Insert Record: construct a sql insert statement and execute it

if (request.getParameter("MM_insert") != null) {

// create the insert sql statement
StringBuffer MM_tableValues = new StringBuffer(), MM_dbValues = new StringBuffer();
for (int i=0; i+1 < MM_fields.length; i+=2) {
String formVal = MM_fields[i+1];
String elem;
java.util.StringTokenizer tokens = new java.util.StringTokenizer(MM_columns[i+1],",");
String delim = ((elem = (String)tokens.nextToken()) != null && elem.compareTo("none")!=0)?elem:"";
String altVal = ((elem = (String)tokens.nextToken()) != null && elem.compareTo("none")!=0)?elem:"";
String emptyVal = ((elem = (String)tokens.nextToken()) != null && elem.compareTo("none")!=0)?elem:"";
if (formVal.length() == 0) {
formVal = emptyVal;
} else {
if (altVal.length() != 0) {
formVal = altVal;
} else if (delim.compareTo("'") == 0) { // escape quotes
StringBuffer escQuotes = new StringBuffer(formVal);
for (int j=0; j < escQuotes.length(); j++)
if (escQuotes.charAt(j) == '\'') escQuotes.insert(j++,'\'');
formVal = "'" + escQuotes + "'";
} else {
formVal = delim + formVal + delim;
}
}
MM_tableValues.append((i!=0)?",":"").append(MM_columns[i]);
MM_dbValues.append((i!=0)?",":"").append(formVal);
}
MM_editQuery = new StringBuffer("insert into " + MM_editTable);
MM_editQuery.append(" (").append(MM_tableValues.toString()).append(") values (");
MM_editQuery.append(MM_dbValues.toString()).append(")");

if (!MM_abortEdit) {
// finish the sql and execute it
Driver MM_driver = (Driver)Class.forName(MM_editDriver).newInstance();
Connection MM_connection = DriverManager.getConnection(MM_editConnection,MM_editUserName,MM_editPassword);
PreparedStatement MM_editStatement = MM_connection.prepareStatement(MM_editQuery.toString());
MM_editStatement.executeUpdate();
MM_connection.close();

// redirect with URL parameters
if (MM_editRedirectUrl.length() != 0) {
response.sendRedirect(response.encodeRedirectURL(MM_editRedirectUrl));
return;
}
}
}
%>
回复
damner 2002-05-27
错误信息如下:
type Exception report

message Internal Server Error

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

exception

javax.servlet.ServletException: [Microsoft][ODBC SQL Server Driver][SQL Server]将截断字符串或二进制数据。
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:463)
at org.apache.jsp.TMP9qkyfwr4i5$jsp._jspService(TMP9qkyfwr4i5$jsp.java:196)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:202)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:382)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:474)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2343)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1012)
at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1107)
at java.lang.Thread.run(Thread.java:536)

回复
tin_dra 2002-05-27
sql的驱动程序不对
把程序贴出来
回复
damner 2002-05-27

我用的是dreamweaverMX,对于BEAN,我不太熟悉,

谢谢你们的帮助、

我先结了。再找找错误
回复
发动态
发帖子
Web 开发
创建于2007-09-28

7.9w+

社区成员

Java Web 开发
申请成为版主
社区公告
暂无公告