title: JDBC Re-read Data In ResultSet
body: <p>I am retrieving a simple ResultSet from my SQL Server database using the Microsoft JDBC Driver (mssqlserver.jar).  I think it is the MSSQL2000 Driver which is downloaded from [Microsoft JDBC][1]</p>
  
  <p>I am wanting to call the getter methods more than once to access the values but when you do the following exception is thrown:</p>
  
  <blockquote>
    <p><code>java.sql.SQLException</code>: [Microsoft][SQLServer 2000 Driver for JDBC]<code>ResultSet</code> can not re-read row data for column 1.</p>
  </blockquote>
  
  <p>Question is, I am retrieving data into a ResultSet.  From the ResultSet, I am accessing the data in my code before passing the ResultSet on to elsewhere in code to be reused.</p>
  
  <p>Code is similar to as follows:</p>
  
  <pre><code>// build query string
  String selectQuery = "SELECT * FROM SomeWhere";
  
  // get the data
  Statement statement = sourceConnection.createStatement();
  ResultSet rs = statement.executeQuery(selectQuery);
  
  while( rs.next() ) {
  
      // do my own internal processing 
      doSomethingWithRs(rs);
  
      // now do something with the record set outside - in subclass
      afterRowCopied(rs);
  }
  
  // ...
  
  private void doSomethingWithRs(ResultSet rs) {
      // access data   
      for( int i = 1; i &lt;= rs.getMetaData().getColumnCount(); i++) {
          Object o = rs.getObject(i);
          // do something with o...
      }
  
  }
  </code></pre>
  
  <p><strong>Edit</strong></p>
  
  <p>I am using Java 1.6 for this.</p>
  
  <p><strong>end Edit</strong></p>
  
  <p>Any thoughts?
  All I can think of doing is repackaging the data with the ResultSetMetaData into a custom class.</p>
  
  <p>Not really found too much posts on this issue.  Microsoft website not any help at all.</p>