文件DbInput.java则是真正的数据拷贝部分:
import java.sql.*;
public class DbInput
{
Connection src=null;
Connection dest=null;
Connection connformax=null;
ConnPara srcPara;
ConnPara destPara;
public DbInput(){}
public void dbInit()
{
DbXmlParser xmlparser=new DbXmlParser("dbs.xml");
srcPara=xmlparser.getSource();
destPara=xmlparser.getDest();
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver" );
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
src = DriverManager.getConnection( srcPara.getUrl(), srcPara.getUsername(),srcPara.getPassWord());
dest =DriverManager.getConnection( destPara.getUrl(), destPara.getUsername(),destPara.getPassword());
connformax= DriverManager.getConnection( destPara.getUrl(), destPara.getUsername(),destPara.getPassword());
}
//捕捉加载驱动程序异常
catch ( ClassNotFoundException cnfex ) {
System.err.PRintln( "装载 JDBC/ODBC 驱动程序失败。" );
cnfex.printStackTrace();
System.exit( 1 ); // terminate program
} catch ( SQLException ex )
{
System.err.println( "连接失败" );
ex.printStackTrace();
System.exit( 1 ); // terminate program
}
}
新闻热点
疑难解答