我现在要把server数据库中的一个表的id字段数据。。导到oracle中一个表的id字段中
我现在使用2个connection交互做。。不过出了些小问题。。
public class A00AirLawBo{ public void importData(Connection sqlCon, Connection oraCon)
throws Exception {
   Statement sqlSta = sqlCon.createStatement();
   ResultSet sqlRs = sqlSta.executeQuery("select * from AIRLAW");
   int id = sqlRs.getInt("id"); 先查出ID      20行(这里报错)
   
   PreparedStatement oraSta = oraCon.prepareStatement("insert into AIRLAW(id) values(?)");
   while(sqlRs.next()){
   oraSta.setInt(1, id); 插进oracle中
   oraSta.execute();
   }
   sqlRs.close();
   oraSta.close();
   sqlSta.close();
}
}
测试方法
public static void main(String args[]){
Connection oraCon = null;
Connection sqlCon = null;
try {
oraCon = new OracleConnection().getConnection();
sqlCon = new SQLServerConection().getConnection();

sqlCon.setAutoCommit(false);
A00AirLawBo a = new A00AirLawBo();
a.importData(sqlCon, oraCon);  //调用上面的方法15行(这里报错)
sqlCon.commit();

} catch (Exception e) {
try {
sqlCon.rollback();
} catch (SQLException e1) {
e1.printStackTrace();
}
e.printStackTrace();
}报错
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Invalid operation for the current cursor position.
at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.microsoft.jdbc.base.BaseResultSet.validateCursorPosition(Unknown Source)
at com.microsoft.jdbc.base.BaseResultSet.getInt(Unknown Source)
at com.microsoft.jdbc.base.BaseResultSet.getInt(Unknown Source)
at com.ninemax.bo.A00AirLawBo.importData(A00AirLawBo.java:15)
at com.ninemax.bo.TableCreator.main(TableCreator.java:20)
}