方案1:導(dǎo)出數(shù)據(jù)庫(kù)文件-導(dǎo)入
方案2:navicat prrmium 數(shù)據(jù)傳輸
相同數(shù)據(jù)庫(kù)軟件之間效果好,不同數(shù)據(jù)庫(kù)軟件之間有一些問(wèn)題
方案3:寫程序,連接舊數(shù)據(jù)庫(kù),取出數(shù)據(jù),連接新數(shù)據(jù)庫(kù),存入數(shù)據(jù)
Class.forName("oracle.jdbc.driver.OracleDriver");
String url = "jdbc:oracle:thin:@"+serverName+":1521:eclipsedb";
Connection connOracle = DriverManager.getConnection(url,"eclipse","888888"); //連接源數(shù)據(jù)源
Statement stmt = connOracle.createStatement();
ResultSet rs = stmt.executeQuery("select * from employee");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection connAccess = DriverManager.getConnection("jdbc:odbc:target","",""); //連接目標(biāo)數(shù)據(jù)源
PreparedStatement pstmt = connAccess.prepareStatement("insert into employee(id,name,department,salary) values(?,?,?,?)");
//循環(huán)裝入數(shù)據(jù)
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();
來(lái)自 http://zhengshuo3527.blog.163.com/blog/static/615348220073381530569/