Reputation: 3581
I have this problem connecting the Grails Database Server which is by default uses the H2 Database (driverClassName: "org.h2.Driver").
What is the way to connect the iReport to the database?
Upvotes: 2
Views: 2236
Reputation: 3562
Step 1: Set Automatic Mixed Mode
In your Grails project edit the DataSource.groovy file to set the jdbc connection to Automatic Mixed Mode (AUTO_SERVER=TRUE). This is needed to enable the H2 database to be accessed by both Grails and iReport at the same time. See here for further info:
url = "jdbc:h2:devDb;AUTO_SERVER=TRUE;MVCC=TRUE;LOCK_TIMEOUT=10000"
Step 2: Add H2 Jar File to iReport
Step 3: Setup the JDBC Connection in iReport
Use the following JDBC config, see 1min 30seconds into this iReport Screencast to see how to set this up.
JDBC Driver: org.h2.Driver
JDBC URL: jdbc:h2:/FULLPATH/devDb;AUTO_SERVER=TRUE;MVCC=TRUE;LOCK_TIMEOUT=10000
As in Talon06's answer the org.h2.Driver driver doesn't appear in the drop down box but can be typed directly. AUTO_SERVER=TRUE must also be in the JDBC URL
Upvotes: 3
Reputation: 1796
Select the JBDC driver then type "org.h2.Driver" in the combobox. Then enter the path to your databse and in the Driver Class Path tab add the h2 database jar from their site.
This worked for me anyhow
Upvotes: 2
Reputation: 2115
When setting up the connection in iReport, choose Database JDBC Connection and for JDBC Driver, choose "HSQLDB (file) (org.hsqldb.jdbcDriver)".
Obviously your DataSources will need to be configured to use a file (rather than in memory), which you then point your iReport data source to, e.g.:
development {
dataSource {
dbCreate = "create-drop"
url = "jdbc:hsqldb:file:<path to file>/devDB;shutdown=true"
}
}
Upvotes: 2