import java.sql.*;
import java.io.*;
public class L_j {
public static void main(String[] args)throws IOException 
{ test();}
public static String test(){
try
{
String driver="com.microsoft.jdbc.sqlserver.SQLServerDriver";
String con="jdbc:microsoft:sqlserver://172.127.10.55:1433;DatabaseName=test";
String user="sa";
String password="";
Class.forName(driver);
System.out.println("驱动sqlserver成功");
Connection conn = DriverManager.getConnection(con,user,password);
System.out.println("连接sqlserver数据库成功");
Statement stmt=conn.createStatement();
String sql="select * from Student";
oraclejdbc();//得到oracle数据表的一个语句块
ResultSet ors=ostmt.executeQuery("select * from xxh_test");//ostmt cannot be resolved
while(ors.next()){
       stmt.executeUpdate("insert into Student values('ors.getString(1)','ors.getString(2)','ors.getString(3)','ors.getString(4)'");

}
ResultSet rs = stmt.executeQuery(sql);
ResultSetMetaData rsmd=rs.getMetaData();
int colcount=rsmd.getColumnCount();

while(rs.next())
{  
  for(int i=0;i<colcount;i++){
  System.out.print(rs.getString(i+1)+"\t");
  }System.out.println();
}
rs.close();
stmt.close();
conn.close();
 
}
catch(Exception ex)
{
System.err.println(ex.getMessage());
}
 
return null;
}  /**create a method
*get oracle for jdbc
*connection
*insert . update. delete*/
public  static Statement oraclejdbc(){
Statement ostmt = null;
try
{
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
System.out.println("找到oracle驱动!");
}
catch(java.lang.ClassNotFoundException e)
{
System.err.print(e.getMessage());
}
String url="jdbc:oracle:thin:@web:1521:oradb";
    Connection oconn=DriverManager.getConnection(url,"compiere","");
System.out.println("oracle驱动连接成功!");
 ostmt=oconn.createStatement();
return ostmt;
}
catch(SQLException ex)
{
while(ex!=null)
{
System.out.println(ex.getSQLState());
}
}return null;
}
}
朋友们我现在想在两个不同的数据库里(SQLSERVER ,ORACLE)从一个数据表取出一些记录添加到另一个数据库的数据表里,实现这两个数据表里同步.看看我这段代码该怎么改才能实现我想要的结果.现在程序出错.就是那个ostmt朋友们帮忙解决下将会非常感谢!