我觉得有必要在这里分享一下我得到解决关于 column can not be re-read 的问题,尽管这篇文章是受网上一篇文章的影响而发
jsp 页面:
view_edit.jsp
1 <jsp:useBean id="listType" class="net.inber.ViewListType" scope="page"/>
2 <jsp:useBean id="ls" class="net.inber.ListsBean" scope="page"/>
3 <%
4 String listsId=request.getParameter("id");
5 Lists lists=ls.getListsInfo(listsId);
6 %>
ListsBean 的部分代码:
21 public Lists getListsInfo(String listsId)throws Exception
22 {
23
24 Statement stmts=con.createStatement();
25 ResultSet rsts=stmts.executeQuery("select * from list_table where id='"+listsId+"'");
26 Lists lists=null;
27 while(rsts.next())
28 {
29
30
31
32 lists=new Lists();
33
34 lists.setItemName(rsts.getString("item_name"));
35 lists.setListTypeId(rsts.getString("list_type_id"));
}
return lists;
}
问题:
我一运行view_edit.jsp就出现如下错误:
[Microsoft][SQLServer 2000 Driver for JDBC]ResultSet can not re-read row data for column 2
开始我以为是1,2,行的bean和第5行的bean发生冲突,后来检查没有问题。。。郁闷得很。。
于是搜索一下baidu 受一文章启发
问题原因:34行item_name 和35行 list_type_id 在数据库中的位置 是list_type_id,item_name 在javabean中通过jdbc访问顺序不对就会再现些问题
解决办法将 34和35对换一下位置编译运行通过!!!
希望您尽快找到这篇文章并对您有所帮助---InberKong
引用原来出处:
利用JDBC连接MS SQL Ser2000+sp2 您要打印的文件是:利用JDBC连接MS SQL
Ser2000+sp2 打印本文
利用JDBC连接MS SQL Ser2000+sp2
作者:佚名 转贴自:本站原创 点击数:8
我在学习j2ee的时候使用jdbc连接过ms sql server
2000,开始的时候一切都正常,但是后来遇到了一个很头痛的问题,就是我们在从表中读取数据放到ResultSet中后,读取列值的时候一定的按照列的顺序读取。
比如如果表中有三列id, name, address,按条件查询得到的结果放到ResultSet中,显示结果时如果这样写代码:
java.sql.ResultSet employees;
while(employees.next()){
employees.getString(address);
employees.getString(name);
}
在运行的时候将会column can not be re-read错误,此时把两条语句颠倒就好了(此条只适用于连接MS SQL
Server 2000)
连接数据库代码如下:
try {
Class.forName(com.microsoft.jdbc.sqlserver.SQLServerDriver);
conn =
DriverManager.getConnection(
jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=Hotel;User=sa;Password=sa);
// Class.forName(sun.jdbc.odbc.JdbcOdbcDriver);
// conn = DriverManager.getConnection(jdbc:odbc:hotel);
} catch (SQLException e) {
System.err.println(e);
} catch (ClassNotFoundException e) {
System.err.println(e);
}
分享到:
相关推荐
To make use of either more or less strict isolation levels in applications, locking can be customized for an entire session by setting the isolation level of the session with the SET TRANSACTION ...
should not hold down the Shift key. * Version 2.67 o Fixed bug: when turning on the 'Image Preview' option, OutlookAttachView displayed empty image or incorrect image. * Version 2.66 o Added ...
The benefit of a column maker is that it can help you to format your text/code, or in some cases to make it easier to read in complex nested logic. Quick Open UltraEdit and UEStudio provide multiple ...
34)..Changed: EurekaLog 7 now can be installed over EurekaLog 6 automatically, with no additional actions/tools EurekaLog 7.4 (7.4.0.0), 26-January-2016 1)....Fixed: Performance issue in DLL exports...
As soon as you're finished modifying an entity the garbage collector will mark the record buffer to be saved to disk and released from memory. Why Dbf By default the files are compatible with dBase ...
+ A comma-delimited data file was not read correctly. A new file reading system was implemented to read files with any type of (unspecified) delimiter between the data columns + if a data file ...
It can be dense or sparse (type must be double). -libsvm_options: A string of training options in the same format as that of LIBSVM. matlab> [predicted_label, accuracy, decision_values/prob_...
* This update can not be removed after it is installed.* You will need the original Delphi 7 installation CD available to install this update.* To install this update from the CD, insert the CD, and ...
when you're creating a new, Ribbon-based application, you can choose "Backstage view" option (see screenshot) and initial backstage view code will be automatically generated for your pleasure!...
@ get read to call C functions (for nand_read()) ldr sp, DW_STACK_START @ setup stack pointer mov fp, #0 @ no previous frame, so fp=0 @ copy U-Boot to RAM ldr r0, =TEXT_BASE mov r1, #0x0 mov r2...
非常好的适应性: A semantically marked up document can be easily adapted to print and alternative browsing devices, like handheld computers and cellular phones, just by linking to a different ...