jdbcodbc-ResultSet前后都能读取

import java.sql.*;

public class TestSql
{
 public static void main(String[] args)
 {
  ResultSet result;
  try
  {
  Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  Connection con = DriverManager.getConnection("jdbc:odbc:myDataSource","sa","");
  Statement stat = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
  result = stat.executeQuery("Select * From publishers");

  while(result.next())
  {
   System.out.println(result.getString(1));
   System.out.println(result.getString(2));
   
  }
  
  System.out.println("--------------------------");
  while(result.previous())
  {
   System.out.println(result.getString(1));
  }
  }
  catch(Exception e)
  {
   System.err.println("error:" + e);
  }
 }
}

你可能感兴趣的:(jdbcodbc-ResultSet前后都能读取)