在oarcle的sql脚本中字段长度超过4000执行会有异常,而在postgresql中超过4000仍可以正常执行,产品同时支持多个数据库,如oracle和postgresql,在基础数据较多时,只能通过导出基础数据相关表的dmp或backup文件进行升级部署。开发的时候以oracle作为开发库,需要将基础数据弄到postgresql制作backup文件,通过程序直接读oracle表写到postgresql。
步骤:
1、修改oracle和postgresql库的ip、用户名和密码;
2、修改库表列表;
3、运行;
public static void main(String[] args) throws Exception
{
long t0 = System.currentTimeMillis();
Class.forName("oracle.jdbc.driver.OracleDriver");
Class.forName("org.postgresql.Driver");
Connection srcCon = null, dstCon = null;
Statement srcStmt = null, dstStmt= null;
PreparedStatement ps = null;
try{
/*创建连接*/
srcCon = DriverManager.getConnection("jdbc:oracle:thin:@192.168.1.12:1521:orcl",
"h2do",