ERROR o.h.e.j.s.SqlExceptionHelper Connection is closed

Viewed 154

When I use DataSourceUtils.getConnection I got this error ERROR o.h.e.j.s.SqlExceptionHelper Connection is closed . Because the previously created connection has been closed. And before I use getConnection() it did not have the problem but it not good performance to create a new connection for every request.

I'm using multitenancy.

Datasource for write

@Primary
@Component
public class InstanceWriteDataSource implements DataSource {

    @Override
    public Connection getConnection() throws SQLException {
        return DataSourceUtils.getConnection(getDataSource());
    }
}

Datasource for read

@Component
public class InstanceReadDataSource implements DataSource {

    @Override
    public Connection getConnection() throws SQLException {
        return DataSourceUtils.getConnection(getDataSource());
    }
}

Do you have any idea about this? Thank you.

0 Answers
Related