Have any questions?
+44 1234 567 890
This is the first blog article on our freshly refurbished blog. It’s been a bit quiet here which we want to change and what is better than a bit of fresh paint for a fresh start. This blog post explains how to add support for SQL Server via the open source jTDS driver. The relevant code was sponsored by thr27, thanks a lot. In case you did something cool with ReportServer that you would like to showcase on our blog, feel free to contact us on info@infofabrik.de.
jTDS is an open source 100% pure java JDBC driver supporting Microsoft SQL Server and Sybase Adaptive Server Enterprise in various versions. We’ve already discussed how to register new JDBC drivers with ReportServer in an earlier article. Basically, all that is needed is to put the .jar file into the WEB-INF/lib directory and to provide ReportServer with a small script implementing a DatabaseHelper for the new driver. ReportServer already comes equipped with a DatabaseHelper for Micorsoft SQL Server. The relevant class is net.datenwerke.rs.base.service.dbhelper.db.mssql.MsSQL. In order to register the jTDS driver all that is to do is to extend the MsSQL class as follows (the code is based on code provided by thr27).
package databasehelper; import net.datenwerke.rs.base.service.dbhelper.db.mssql.MsSQL import net.datenwerke.rs.scripting.service.scripting.scriptservices.GlobalsWrapper; import net.datenwerke.rs.base.service.dbhelper.DatabaseHelper import net.datenwerke.rs.base.service.dbhelper.hooks.DatabaseHelperProviderHook class JTDSSqlServer extends MsSQL { public static final String DB_NAME = "JTDS SqlServer"; public static final String DB_DRIVER = "net.sourceforge.jtds.jdbc.Driver"; public static final String DB_DESCRIPTOR = "DBHelper_JTDSSqlServer"; @Override public String getDescriptor() { return DB_DESCRIPTOR; } @Override public String getDriver() { return DB_DRIVER; } @Override public String getName() { return DB_NAME; } } def HOOK_NAME = "DATASOURCE_HELPER_JTDSSQLSERVER" def callback = [ provideDatabaseHelpers : { return Collections.singletonList(new JTDSSqlServer()); } ] as DatabaseHelperProviderHook; GLOBALS.services.callbackRegistry.attachHook(HOOK_NAME, DatabaseHelperProviderHook.class, callback)
All that is left is to execute the script as discussed here.