Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection Pooling timeout doesn't rerun Bootstrap on new Connection #2

Closed
swalton00 opened this issue Sep 19, 2020 · 2 comments
Closed

Comments

@swalton00
Copy link

In MyBatis Bootstrap I issue an H2 "Set Schema" so I can omit the schema from the SQL (and change environments by changing Schemas). The problem is that if the application is idle for a short time, the Connection passes its idle timeout and is closed. When a new connection is opened, the set schema is not reissued, so the next SQL statement fails.

I can see several possible approaches to fixing this: the simplest is to eliminate the connection pooling entirely and simple create one (long-term) connection and closing it during shutdown. As a DBA, I'm in favor of this because, if every desktop app opened 5 connections (the current default), the database would quickly run out of connections. As the code is currently written, it is extremly unlikely that the application could ever use two connections, let alone five.
A second approach could be to issue the Bootstrap every time a connection is opened. And still another approach would be to provide a "pre-SQL" to be issued prior to every MyBatis statement.

The net result of this issue is that SQL statements work for a period of time, and then, after an idle period, they all fail (even ones that were succesfully issued a short time before).

@swalton00
Copy link
Author

I can work around this by setting the Schema in the URL (append ";SCHEMA=RR" to the URL)

@swalton00
Copy link
Author

This is working as it should be - to allow creation of tables on the first connection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant