1212import java .sql .*;
1313import java .sql .Date ;
1414import java .util .*;
15+ import javax .naming .CommunicationException ;
1516import javax .swing .*;
1617
1718
@@ -45,12 +46,16 @@ public class jTPCCTerminal implements jTPCCConfig, Runnable
4546 jTPCCConnection db = null ;
4647 int dbType = 0 ;
4748
49+ private String database = "" ;
50+ private Properties dbProps = null ;
51+
4852 public jTPCCTerminal
4953 (String terminalName , int terminalWarehouseID , int terminalDistrictID ,
5054 Connection conn , int dbType ,
5155 int numTransactions , boolean terminalWarehouseFixed ,
5256 int paymentWeight , int orderStatusWeight ,
53- int deliveryWeight , int stockLevelWeight , int numWarehouses , int limPerMin_Terminal , jTPCC parent ) throws SQLException
57+ int deliveryWeight , int stockLevelWeight , int numWarehouses , int limPerMin_Terminal , jTPCC parent ,
58+ String database , Properties dbProp ) throws SQLException
5459 {
5560 this .terminalName = terminalName ;
5661 this .conn = conn ;
@@ -75,6 +80,8 @@ public class jTPCCTerminal implements jTPCCConfig, Runnable
7580 this .numWarehouses = numWarehouses ;
7681 this .newOrderCounter = 0 ;
7782 this .limPerMin_Terminal = limPerMin_Terminal ;
83+ this .database = database ;
84+ this .dbProps = dbProp ;
7885
7986 this .db = new jTPCCConnection (conn , dbType );
8087
@@ -165,6 +172,15 @@ private void executeTransactions(int numTransactions)
165172 {
166173 continue ;
167174 }
175+ catch (SQLException e ){
176+ try {
177+ Connection conn = DriverManager .getConnection (database , dbProps );
178+ conn .setAutoCommit (false );
179+ db = new jTPCCConnection (conn , dbType );
180+ } catch (SQLException ex ) {
181+ throw new RuntimeException (ex );
182+ }
183+ }
168184 catch (Exception e )
169185 {
170186 log .fatal (e .getMessage ());
0 commit comments