标签:while result acl link ica nbsp eclips bcd ofo
方案1:导出数据库文件-导入
方案2:navicat prrmium 数据传输
相同数据库软件之间效果好,不同数据库软件之间有一些问题
方案3:写程序,连接旧数据库,取出数据,连接新数据库,存入数据
Class.forName("oracle.jdbc.driver.OracleDriver");
String url = "jdbc:oracle:thin:@"+serverName+":1521:eclipsedb";
Connection connOracle = DriverManager.getConnection(url,"eclipse","888888"); //连接源数据源
Statement stmt = connOracle.createStatement();
ResultSet rs = stmt.executeQuery("select * from employee");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection connAccess = DriverManager.getConnection("jdbc:odbc:target","",""); //连接目标数据源
PreparedStatement pstmt = connAccess.prepareStatement("insert into employee(id,name,department,salary) values(?,?,?,?)");
//循环装入数据
while(rs.next()) {
pstmt.setInt(1,rs.getInt("id"));
pstmt.setString(2,rs.getString("name"));
pstmt.setString(3,rs.getString("department"));
pstmt.setDouble(4,rs.getDouble("salary"));
pstmt.executeUpdate();
}
//释放资源
rs.close();
stmt.close();
pstmt.close();
connOracle.close();
connAccess.close();
来自 http://zhengshuo3527.blog.163.com/blog/static/615348220073381530569/
标签:while result acl link ica nbsp eclips bcd ofo
原文地址:http://www.cnblogs.com/Lulus/p/7874312.html