Forum: Other

Post: How to connect VoltDB with JDBC?

How to connect VoltDB with JDBC?
2170p
Jan 14, 2014
Hi everyone,

I'm testing VoltDB simply how it just works in my environment.
I'm trying out VoltDB via load testing tool, JDBCRunner with the simple test script below.
Yet I am not sure how to connect the tool to VoltDB.

===================="test.js"(script)========================
var jdbcDriver = "org.voltdb.jdbc.Driver";
var jdbcUrl = "jdbc:voltdb://IP Addr.:Port";
//var jdbcUser = "test";
//var jdbcPass = "test";

function run() {
var param = random(1, 5);
query("SELECT data FROM tutorial WHERE id = $int", param);
}
======================================================


I installed VoltDB, and created the sample data table according to the Tutorial guide.
Then complied the schema file and start VoltDB.
When I execute simple script via JDBC, some error appears as below.

===================Error message========================
Exception in thread "agent0" java.lang.NoClassDefFoundError: com/google ase/Supplier
at org.voltdb.client.Distributer.<init>(Distributer.java:119)
at org.voltdb.client.ClientImpl.<init>(ClientImpl.java:89)
at org.voltdb.client.ClientFactory.createClient(ClientFactory.j
at org.voltdb.jdbc.JDBC4ClientConnection.<init>(JDBC4ClientConn va:138)
at org.voltdb.jdbc.JDBC4ClientConnectionPool.get(JDBC4ClientCon ol.java:83)
at org.voltdb.jdbc.Driver.connect(Driver.java:91)
at org.apache.commons.dbcp.DriverConnectionFactory.createConnec erConnectionFactory.java:38)
at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject ConnectionFactory.java:582)
at org.apache.commons.dbcp.BasicDataSource.validateConnectionFa icDataSource.java:1556)
at org.apache.commons.dbcp.BasicDataSource.createPoolableConnec ry(BasicDataSource.java:1545)
at org.apache.commons.dbcp.BasicDataSource.createDataSource(Bas rce.java:1388)
at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicD .java:1044)
at jdbcrunner.Manager.getConnection(Manager.java:224)
at jdbcrunner.Agent.callInit(Agent.java:222)
at jdbcrunner.Agent.run(Agent.java:86)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.ClassNotFoundException: com.google.common.base.Sup
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 16 more
=======================================================

It seems that JDBC Driver doesn't work.
Yet I have already set jar file, and CLASSPATH.
(CLASSPATH=/****/voltdbclient-3.7.jar )

Does anyone have ideas?

Sorry for my newbie question.
Thanks.
Louis


Environment (VM)
RHEL 6.3, CPU 2GHz 4 core, Memory 8GB
bballard
Jan 14, 2014
Hi Louis,

In VoltDB 3.7, you need to include the guava-12.0.jar file in your CLASSPATH for java clients using either the native java client library or the JDBC driver. The file is provided in the kit under lib/guava-12.0.jar. For VoltDB 4.0, which will be available to the public for download later this month, the guava library has been embedded into the JDBC driver file so there are no external dependencies.

-Ben
2170p
Jan 15, 2014
Hi Ben,

It went well.
I appreciate your advice.

- Louis
Munkhdalai
Jul 9, 2014
i am confused in jdbc driver. What type of jdbc driver is using? Can you give me direct link download jdbc driver?
pzhao
Jul 9, 2014
Munkhdalai,

Jdbc driver is now included in our server/client kit, specifically voltdb/voltdbclient-n.n.jar for the client. An example of its use can be found in examples/voter.
Here is documentation of JDBC interface on our website: https://voltdb.com/docs/UsingVoltDB/ProgLangjdbc.php
If you have any other questions, feel free to reach out to us.

-Peter