#1 2015-10-27 15:22:55

thr27
Member
Registered: 2015-10-27
Posts: 2

SQL Server jTDS Support

In case anyone needs support for sourceforge jTDS Jdbc Access to SQLServer.

Pls. find attached the groovy script to install.

How to install new jdbc Support for any database is explained here .

jTDS supports access to SQL Server with Domain NTLM User/Password. This does not work with the Microsoft SQL Server JDBC Driver from Linux.

package databasehelper;

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
import net.datenwerke.rs.base.service.dbhelper.queries.LimitQuery
import net.datenwerke.rs.base.service.dbhelper.queries.OffsetQuery;
import net.datenwerke.rs.base.service.dbhelper.queries.OrderQuery;
import net.datenwerke.rs.base.service.dbhelper.queries.Query
import net.datenwerke.rs.base.service.dbhelper.querybuilder.ColumnNamingService
import net.datenwerke.rs.base.service.dbhelper.querybuilder.QueryBuilder
import net.datenwerke.rs.base.service.dbhelper.db.mssql.MsSQLLimitQuery;
import net.datenwerke.rs.base.service.dbhelper.db.mssql.MsSQLOffsetQuery;
import net.datenwerke.rs.base.service.dbhelper.db.mssql.MsSQLOrderQuery;

class JTDSSqlServer extends DatabaseHelper {

	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;
	}
	public String createDummyQuery()
  	{
    	return "SELECT 1 as A";
  	}

  	public LimitQuery getNewLimitQuery(Query nestedQuery, QueryBuilder queryBuilder)
  	{
    	return new MsSQLLimitQuery(nestedQuery, queryBuilder);
  	}

  	public OffsetQuery getNewOffsetQuery(Query nestedQuery, QueryBuilder queryBuilder, ColumnNamingService columnNamingService)
  	{
    	return new MsSQLOffsetQuery(nestedQuery, queryBuilder, columnNamingService);
  	}

  	public OrderQuery getNewOrderQuery(Query nestedQuery, QueryBuilder queryBuilder, ColumnNamingService columnNamingService)
  	{	
    	return new MsSQLOrderQuery(nestedQuery, queryBuilder, columnNamingService);
  	}
	
}


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)

Offline

#2 2015-10-31 13:07:33

Arno Mittelbach
datenwerke
Registered: 2012-02-14
Posts: 690

Re: SQL Server jTDS Support

Hey,

thanks for this. I've transformed this tip into a small blog post.

Cheers
-Arno

Offline

Board footer

Powered by FluxBB