Forum: Building VoltDB Clients

Post: About java driver

About java driver
vuser
Mar 4, 2013
Hello.
I have some questoins about java driver for web develop:
1. is thread save?
2. is has connection pool?
3. need to close connection after async call procedure?
Thanks.
bballard
Mar 4, 2013
Hi,

The java driver Client class is thread-safe. If you review the examples/voter/src/voter/SyncBenchmark.java code, you can see that one Client object is used simultaneously by many threads. For this reason, it is generally not necessary to use connection pooling.

The connection only needs to be closed before the client application exits, not after async call procedure. The examples/voter/src/voter/AsynchBenchmark.java class has examples of async calls. You might also want to review some further examples on Volt Labs (https://github.com/VoltDB/voltdb-labs).

The "stored_value_cards" example (https://github.com/VoltDB/voltdb-labs/tree/master/java/stored_value_cards/client/src) has a reusable BenchmarkCallback class which includes atomic counters for multiple stored procedures. This example is similar in operation to the voter benchmark, but may be easier to modify for your own use case.

Thanks,
Ben
vuser
Mar 5, 2013
Thanks for answer!