I'm adding a downloaded jar to my lib folder, but when I try to use it doesn't work.
Here is the code:
// make sure the ClassLoader has the MonetDB JDBC driver loaded
Class cls = Class.forName("nl.cwi.monetdb.jdbc.MonetDriver");
// request a Connection to a MonetDB server running on 'localhost'
Connection con = DriverManager.getConnection("jdbc:monetdb://localhost/testDB", "monetdb", "monetdb");
Statement st = con.createStatement();
There is no code problems because I created a java app with same code and it works, the problem is grails is not taking the jar into the class path. So finaly here is my buildConfig.groovy
grails.project.dependency.resolver = "maven" // or ivy
grails.project.dependency.resolution = {
// inherit Grails' default dependencies
inherits("global") {
// uncomment to disable ehcache
// excludes 'ehcache'
}
log "warn" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
repositories {
grailsCentral()
mavenLocal()
mavenCentral()
// uncomment the below to enable remote dependency resolution
// from public Maven repositories
//mavenRepo "http://repository.codehaus.org"
//mavenRepo "http://download.java.net/maven/2/"
//mavenRepo "http://repository.jboss.com/maven2/"
}
dependencies {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg.
// runtime 'mysql:mysql-connector-java:5.1.27'
}
plugins {
build ":tomcat:8.0.22"
build(":release:3.0.1",
":rest-client-builder:1.0.3") {
export = false
}
}
Take a look at this document: http://grails.github.io/grails-doc/latest/guide/conf.html#dataSource
Define the monetdb as a dependency using BuildConfig.groovy by adding this 'monetdb:monetdb-jdbc:2.8'
Then update the entries in the Datasource.groovy file.
Now from your controller yuo have to inject the datasource.
SampleController{
def dataSource
def index(){
def sql = new Sql(dataSource)
sql.executeUpdate('select * from testdb.something')
}
}