Skip to content

Commit

Permalink
fix: timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
devezhao committed Apr 6, 2023
1 parent a76718f commit d11432b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>cn.devezhao</groupId>
<artifactId>persist4j</artifactId>
<version>1.6.2</version>
<version>1.6.3</version>
<packaging>jar</packaging>

<name>persist4j</name>
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/cn/devezhao/persist4j/engine/JdbcSupport.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ public Object doInParameters(PreparedStatement pstmt) {
int[] rowsAffected;
try {
stmt = connect.createStatement();

stmt.setQueryTimeout(getTimeout());

if (SqlHelper.supportsBatchUpdates(connect)) {
stmt.setQueryTimeout(TIMEOUT_DEFAULT * 3);
for (String sql : sqls) {
if (LOG.isDebugEnabled()) {
LOG.debug("add sql to batch: " + sql);
Expand All @@ -90,7 +90,6 @@ public Object doInParameters(PreparedStatement pstmt) {
}
rowsAffected = stmt.executeBatch();
} else {
stmt.setQueryTimeout(TIMEOUT_DEFAULT);
rowsAffected = new int[sqls.length];
for (int i = 0; i < sqls.length; i++) {
String crtSql = sqls[i];
Expand Down Expand Up @@ -129,7 +128,7 @@ protected ResultSet nativeQuery(String sql) throws SQLException, DataAccessExcep

try {
stmt = connect.createStatement();
stmt.setQueryTimeout(180);
stmt.setQueryTimeout(getTimeout());
if (LOG.isDebugEnabled()) {
LOG.debug("exec query: " + sql);
}
Expand Down

0 comments on commit d11432b

Please sign in to comment.