Have any questions?
+44 1234 567 890
In our last post we have outlined the general process on how to add support for additional databases to ReportServer. Today we will give another example by explaining the necessary steps on how to access a Vertica database with ReportServer.
The process is pretty much the same, we also start by writing a script that defines a new implementation of DatabaseHelper:
class Vertica extends DatabaseHelper { public static final String DB_NAME = "Vertica"; public static final String DB_DRIVER = "com.vertica.jdbc.Driver"; public static final String DB_DESCRIPTOR = "DBHelper_Vertica"; @Override public String getDescriptor() { return DB_DESCRIPTOR; } @Override public String getDriver() { return DB_DRIVER; } @Override public String getName() { return DB_NAME; } @Override public String createDummyQuery() { return 'select 1 from dual'; } }
In the next step we add the necessary calls to the script, to register the new driver with ReportServer
def HOOK_NAME = "DATASOURCE_HELPER_VERTICA" def callback = [ provideDatabaseHelpers : { return Collections.singletonList(new Vertica()); } ] as DatabaseHelperProviderHook; GLOBALS.services.callbackRegistry.attachHook(HOOK_NAME, DatabaseHelperProviderHook.class, callback)
The complete script is available for download here: AddVerticaSupport.groovy
Before you proceed, you have to add the Vertica jdbc driver to your classpath.
Download the driver from my.vertica.com and place it in the WEB-INF/lib subdirectory of your ReportServer installation. You might have to restart ReportServer afterwards.
Now open ReportServer and change to the filesystem admin module. Put the script somewhere below the bin directory in the fileserver.
To execute the script open the terminal by pressing CTRL+ALT+T and use the cd command to change into the directory where you placed the script
cd /fileserver/bin
Execute the script by typing
exec -g AddVerticaSupport.groovy
The -g argument is important, to execute the script in the global context. Otherwise the new DatabaseHelper will only be present in your current session. After pressing F5 to reload your browser you will be able to select Vertica as the database type, when creating a new datasource.
Beware, that after restarting ReportServer hooks attached from the terminal will no longer be present. To automatically attach a hook on startup put the script in the bin/onstartup.d directory in the fileserver.