I am trying to create a set of test scripts that will perform black-box testing of something that works with database. For that I need to issue SQL commands from standard input or file, which was quite possible with "mysql" client, but now we use other database, which has only jdbc driver. I need the same basic functionality in command line as mysql client has, but for any jdbc powered database. Is that possible without programming my custom java tool?
There are two timeout settings: Max Wait Time: Amount of time the caller (the code requesting a connection) will wait before getting a connection timeout. The default is 60 seconds.
It's better to use a thread-pool to give you a Connection as a local variable, and close it when the method exits to return it to the pool. If you don't close it, it leaks, and ties up server resources.
It's a common Java coding practice to close any resource in finally block as soon as we are done using the resource. JDBC connection and classes are a costly resource and should be closed in finally block to ensure the release of connection even in the case of any SQLException .
At the end of your JDBC program, it is required explicitly to close all the connections to the database to end each database session. However, if you forget, Java's garbage collector will close the connection when it cleans up stale objects.
This one is pretty commonly used, works with any SQL database, and is pretty well supported: https://github.com/julianhyde/sqlline
I've had success with jisql for Oracle and Postgres databases, and it appears to support most databases with JDBC drivers:
http://sourceforge.net/projects/jisql/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With