This commit is contained in:
Kane Wang 2021-06-25 11:30:31 +08:00
parent 4878541b65
commit fa9385a064
4 changed files with 43 additions and 63 deletions

View File

@ -445,8 +445,6 @@ public class DataImport
Class.forName( "oracle.jdbc.driver.OracleDriver" );
callStmt = oracleConnection.prepareCall( callProcedureSql );
oracleConnection.setAutoCommit( false );
for ( TelsalePolicyRecord recordIterator : policyList )
{
callStmt.setString( 1, recordIterator.getPolicyNo() );
@ -558,38 +556,45 @@ public class DataImport
" today)";
statement = conn.prepareStatement( insertSQL );
statement = conn.prepareStatement( insertSQL );
for ( TelsalePolicyRecord recordIterator : policyList )
for ( TelsalePolicyRecord recordIterator : policyList )
{
statement.setString( 1, recordIterator.getPolicyNo() );
statement.setString( 2, recordIterator.getOperatorCode() );
statement.setString( 3, recordIterator.getOperatorName() );
statement.setString( 4, recordIterator.getOperatorSectionOfficeCode() );
statement.setString( 5, recordIterator.getOperatorSectionOfficeName() );
statement.setString( 6, recordIterator.getOperatorDepartmentCode() );
statement.setString( 7, recordIterator.getOperatorDepartmentName() );
try
{
statement.setString( 1, recordIterator.getPolicyNo() );
statement.setString( 2, recordIterator.getOperatorCode() );
statement.setString( 3, recordIterator.getOperatorName() );
statement.setString( 4, recordIterator.getOperatorSectionOfficeCode() );
statement.setString( 5, recordIterator.getOperatorSectionOfficeName() );
statement.setString( 6, recordIterator.getOperatorDepartmentCode() );
statement.setString( 7, recordIterator.getOperatorDepartmentName() );
try
{
statement.execute();
}
catch ( SQLException error )
{
//捕捉写入错误
errorMessage += "保单号" +
recordIterator.getPolicyNo() +
"保存失败,错误提示:" +
error.getMessage() + "<br>\n";
errorCount++;
}
statement.execute();
}
catch ( SQLException error )
{
//捕捉写入错误
errorMessage += "保单号" +
recordIterator.getPolicyNo() +
"保存失败,错误提示:" +
error.getMessage() + "<br>\n";
errorCount++;
}
}
//检查错误数量如果有错误就抛出异常
if ( errorCount > 0 )
{
throw new TelsalePolicyDataSaveToInformixException( errorMessage );
}
}
/**
* @Description:
* @Description: 读取excel文件将数据写入oracle和informix数据库
* 数据库连接关闭自动提交在两个数据库都写入成功后提交
* 只要有一个数据库写入抛出异常回滚两个数据库的事务
* @Param:
* @return: void
* @Author: 王炜
@ -624,8 +629,15 @@ public class DataImport
try
{
//saveTelsalePolicyDataToOracle( oracleConnection, policyList );
oracleConnection.setAutoCommit( false );
informixConnection.setAutoCommit( false );
saveTelsalePolicyDataToOracle( oracleConnection, policyList );
saveTelsalePolicyDataToInformix( informixConnection, policyList );
oracleConnection.commit();
informixConnection.commit();
}
catch ( Exception error )
{
@ -635,22 +647,6 @@ public class DataImport
throw new TelsalePolicyDataSaveToDatabaseException( error.getMessage() );
}
// catch ( TelsalePolicyDataSaveToInformixException error )
// {
// //写入informix错误回滚两个数据库再抛出异常
// oracleConnection.rollback();
// informixConnection.rollback();
//
// throw new TelsalePolicyDataSaveToDatabaseException( error.getMessage() );
// }
// catch (SQLException error )
// {
// //任何其他sql错误回滚两个数据库再抛出异常
// oracleConnection.rollback();
// informixConnection.rollback();
//
// throw error;
// }
finally
{
//无论如何要关闭连接

View File

@ -37,7 +37,7 @@
</context-param>
<context-param>
<param-name>dxbd_test</param-name>
<param-value>jdbc:informix-sqli://10.39.0.92:9096/ywgl_xm:INFORMIXSERVER=pxmcx2;newcodeset=GBK,8859-1,819;user=ccx99;password=ct0IT17!</param-value>
<param-value>jdbc:informix-sqli://10.39.0.92:16192/ywgl_xm:INFORMIXSERVER=xmcx2;newcodeset=GBK,8859-1,819;user=ccx99;password=c92IT09</param-value>
</context-param>
<context-param>
<param-name>ora_telsale_url</param-name>

View File

@ -1,6 +1,6 @@
create table
(
varchar2(20),
varchar2(20) primary key,
varchar2(20),
varchar2(100),
varchar2(20),

View File

@ -4,21 +4,9 @@ PL/SQL Developer Project Desktop
SavePath=D:\develop\projects_win\2018\telsale_management_2017\덜쯤\oracle\淃커\
Index=1
DPI=96
Left=0
Top=0
Width=1550
Height=719
State=0
Type=0
ChildListIndex=3
WindowName=TELSALE.电销保单信息表@DEV01
Pinned=0
Index=2
Filename=D:\develop\projects_win\2018\telsale_management_2017\덜쯤\oracle\淃커\관\telsale_policy_check_pkg.pck
VCSDBObject=0
Connection=284741774427458141914393448343813479491342034357449534493235319731913185332349975023472932994861479148014811
Connection=203611904672479448844638482446903692419849284826467636303960398639804038366443144308449440244018359636063616
DPI=96
Left=0
Top=0
@ -29,10 +17,6 @@ Type=3
ChildListIndex=1
Pinned=0
Index=3
Filename=
Connection=288540874337449141654431439345473389501542414363446935513241329932613223336131153141342348734899482948394721
[Files]
[MRU]