I have a customer that asked me to build a Vertica environment and connect it to JasperReports. Fun!
So, it took a while (mostly due to technical difficulties on my end), but it works. And I thought I’d document how.
- Install Vertica. That’s an easy task, lots of documentation on the Vertica site. Frankly – I haven’t read any of it. Just clickty-click and you’re done.
- Create the Vertica database. Use
/opt/vertica/bin/adminTools
for that. Make sure you run it under thedbadmin
user (usesu - dbadmin
if you have problems to login directly). - Install Tomcat. I used Tomcat 6, but 7 is supported too.
- Install JasperReports Server (can be downloaded here). I used the WAR file version (had problems with the X Windows support over SSH) – see installation documentation here. This was not the easiest thing to do.
- Copy the Vertica JDBC driver to Tomcat (from
/opt/vertica/java/lib/vertica_5.1.1_jdk_5.jar
toTOMCAT_HOME/lib
) - Start Tomcat (using
TOMCAT_HOME/bin/startup.sh
) - Log in to the Jasper Reports application at
http://your_host:8080/jasperreports
. Default username isjasperreports
and the password isjasperreports
too. Create a new DataSource in Jasper. For driver class entercom.vertica.jdbc.Driver
. For URL enterjdbc:vertica://vertica_host:5433/db_name
. User isdbadmin
and password is the database password you entered when you created the database-
update
Turns out I was overly optimistic. Although Jasper UI shows the connection works, reports can’t run with this connection. You need to use a JNDI Data Source connection. Easy to do:
- Open the
context.xml
file in theTOMCAT_HOME/webapps/jasperreports/META-INF
- Add the following lines:
<Resource name="jdbc/vertica" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="dbadmin" password="test"
driverClassName="com.vertica.jdbc.Driver"
url="jdbc:vertica://localhost:5433/test" /> - Now create a JNDI based data source in Jasper (see here for more details)
- I have also saw that the
TOMCAT_HOME/conf/Catalina/default/jasperreports.xml
file needs to be updated, and contain the same code snippet from above. I have no clue why Tomcat doesn’t update this file automatically. - Restart the Tomcat server
- Open the
That’s it. Hope it helped 😉