Skip to content

Commit 8b12098

Browse files
committed
retry
1 parent b1b0e32 commit 8b12098

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

src/client/jTPCC.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ else if(newOrderWeightValue == 0 && paymentWeightValue == 0 && orderStatusWeight
484484
conn, dbType,
485485
transactionsPerTerminal, terminalWarehouseFixed,
486486
paymentWeightValue, orderStatusWeightValue,
487-
deliveryWeightValue, stockLevelWeightValue, numWarehouses, limPerMin_Terminal, this);
487+
deliveryWeightValue, stockLevelWeightValue, numWarehouses, limPerMin_Terminal, this, database, dbProps);
488488

489489
terminals[i] = terminal;
490490
terminalNames[i] = terminalName;

src/client/jTPCCConnection.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,7 @@ public void commit()
307307
throws SQLException
308308
{
309309
try {
310-
if (dbConn != null && !dbConn.isClosed()) {
311-
dbConn.commit();
312-
}
310+
dbConn.commit();
313311
} catch(SQLException e) {
314312
throw new CommitException();
315313
}
@@ -318,8 +316,6 @@ public void commit()
318316
public void rollback()
319317
throws SQLException
320318
{
321-
if (dbConn != null && !dbConn.isClosed()) {
322319
dbConn.rollback();
323-
}
324320
}
325321
}

src/client/jTPCCTerminal.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import java.sql.*;
1313
import java.sql.Date;
1414
import java.util.*;
15+
import javax.naming.CommunicationException;
1516
import 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

Comments
 (0)