text, ntext, image data type을 조회할 때 아래와 같은 에러 발생시 해결 방법
[Microsoft][SQLServer 2000 Driver for JDBC]ResultSet can not re-read row data for column 1.
SELECT문에서 사용된 칼럼을 좌에서 우로 단 한번만 조회해야 된다는군요..
create table myTable (fld1 int, fld2 varchar(20), remark text);
insert into myTable values (1, ‘Joseph’, ‘Text for Joseph’);
insert into myTable values (2, ‘Michael’, ‘Text for Michael’);
insert into myTable values (3, ‘Thomas’, ‘Text for Thomas’);
insert into myTable values (1, ‘Joseph’, ‘Text for Joseph’);
insert into myTable values (2, ‘Michael’, ‘Text for Michael’);
insert into myTable values (3, ‘Thomas’, ‘Text for Thomas’);
Class.forName(“com.microsoft.jdbc.sqlserver.SQLServerDriver” );
Connection connection = DriverManager.getConnection(“jdbc:microsoft:sqlserver://server:1433;
databasename=pubs;SelectMethod=direct”, ““,”“);
Statement stmt = connection.createStatement();
String s = “SELECT fld1, fld2, remark FROM myTable”;
ResultSet rs = null;
rs = stmt.executeQuery(s);
System.out.println(“Success! The following are the rows in this query:”);
int fld1;
String fld2;
String remark;
while (rs.next())
{
remark = rs.getString(“remark”); //fails if in this order
fld1 = rs.getInt(“fld1”);
fld2 = rs.getString(“fld2”);
//remark = rs.getString(“remark”); //works fine if in this order
System.out.println(fld1 + “, ” + fld2 + “, ” + remark);
}
rs.close();
stmt.close();
connection.close();
Connection connection = DriverManager.getConnection(“jdbc:microsoft:sqlserver://server:1433;
databasename=pubs;SelectMethod=direct”, “
Statement stmt = connection.createStatement();
String s = “SELECT fld1, fld2, remark FROM myTable”;
ResultSet rs = null;
rs = stmt.executeQuery(s);
System.out.println(“Success! The following are the rows in this query:”);
int fld1;
String fld2;
String remark;
while (rs.next())
{
remark = rs.getString(“remark”); //fails if in this order
fld1 = rs.getInt(“fld1”);
fld2 = rs.getString(“fld2”);
//remark = rs.getString(“remark”); //works fine if in this order
System.out.println(fld1 + “, ” + fld2 + “, ” + remark);
}
rs.close();
stmt.close();
connection.close();
위 에러와 관련된 내용은 다음 웹페이지에서 볼 수 있습니다.
http://support.microsoft.com/default.aspx?scid=kb;en-us;824106
아래 사이트에 있는 JDBC 드라이버를 사용해도 되는군요..
http://sourceforge.net/project/showfiles.php?group_id=101692