Skip to content

Commit

Permalink
Return reopened connection if closed
Browse files Browse the repository at this point in the history
  • Loading branch information
ssheikin committed Nov 13, 2024
1 parent 3a579b8 commit 446610b
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,14 @@

package io.trino.tempto.query;

import com.google.inject.Inject;
import io.trino.tempto.context.TestContext;
import org.slf4j.Logger;

import com.google.inject.Inject;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Arrays;

import static io.trino.tempto.query.QueryResult.forSingleIntegerValue;
import static io.trino.tempto.query.QueryResult.toSqlIndex;
Expand Down Expand Up @@ -87,8 +85,13 @@ public QueryResult executeQuery(String sql, QueryParam... params)
@Override
public Connection getConnection()
{
if (connection == null) {
openConnection();
try {
if (connection == null || connection.isClosed()) {
openConnection();
}
}
catch (SQLException e) {
throw new RuntimeException(e);
}
return connection;
}
Expand Down

0 comments on commit 446610b

Please sign in to comment.