The following is a (rough) translation of a post by Fátima Casaú Pérez I picked up via twitter. To see the original post go to http://blogs.salenda.es/fatima_casau/2009/09/30/inyectar-un-datasource-ingres-en-grails/:
Recently I found the need to use a DAO data source based on an external library in my application. In fact a different data source from my application against which I needed to connect an Ingres database. First off it sounded quite difficult but in the end it was really easy to do.
The fact that it was Ingres and not another RDBMS such as Oracle or MySQL presented no problems. Not even if it’s going to be the database administration for the application. I’ve come across this sort of situation before and haven’t had any problems apart from some data-type incompatibilities, nothing serious.
It was no problem that I needed to use different data source in my application, Just give the source a different name and that’s it. How and where to install? I edited resources.xml adding the new data source and the bean that references the DAO, like so:
<!--- resources.xml -->
< ?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="dataSourceIngres">
<property name="driverClassName" value="ca.ingres.jdbc.IngresDriver" />
<property name="url" value="jdbc:ingres://DATABASE" />
<property name="username" value="USERNAME" />
<property name="password" value="PASSWORD" />
</bean>
<bean id="ingresDao" factory-method="getInstance">
<property name="dataSource"><ref local="dataSourceIngres"/></property>
</bean>
</beans>
After that you call getInstance() for the DAO in the application which in turn calls the corresponding method passing the necessary arguments.
—–
Editor’s note: Fátima is using the driver class ca.ingres.jdbc.IngresDriver and not com.ingres.jdbc.IngresDriver since the client is using Ingres 2.6.