Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are there any mature command line JDBC clients? [closed]

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?

like image 880
Illarion Kovalchuk Avatar asked Jun 21 '12 12:06

Illarion Kovalchuk


People also ask

How long does a JDBC connection last?

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.

What would happen if the connections used in JDBC applications are never closed?

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.

Is it a good practice to close JDBC resources after they have been used?

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 .

Do we need to close JDBC connection?

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.


2 Answers

This one is pretty commonly used, works with any SQL database, and is pretty well supported: https://github.com/julianhyde/sqlline

like image 170
Brent Avatar answered Sep 19 '22 18:09

Brent


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/

like image 35
lreeder Avatar answered Sep 22 '22 18:09

lreeder