Using sqlite with Grails
http://flnkr.com/2011/06/using-sqlite-with-grails/ I’m working on a relatively small application for a some folks without an IT staff. In an effort to simplify the deployment,I’m planning on using H2 as the production database. It will work just fine for five users,and will prevent them from having to install and maintain MySQL or something else. H2 is the default database in Grails,but you’ll need to make some changes to the production configuration for using a file-based H2 database with Tomcat. Here is the production section of my production { dataSource { dbdir ="${System.properties['catalina.base']}/db/sample" dbCreate ="update" url ="jdbc:h2:file:${dbdir};MVCC=TRUE;LOCK_TIMEOUT=10000" pooled =true username ="sa" password ="db!admin" properties { maxActive =-1 minEvictableIdleTimeMillis=1800000 timeBetweenEvictionRunsMillis=1800000 numTestsPerEvictionRun=3 testOnBorrow=true testWhileIdle=true testOnReturn=true validationQuery="SELECT 1"}}} Line 3 sets the location and name of the database file. In this case,I’m reading the system property set by Tomcat to determine the location of running instance ( On line 5,you’ll want to use update or validate as the Finally,on line 6,we build the full datasource URL,substituting in the file location we built above on line 3. I’m setting a password for the database on line 9,but that is optional and really depends on how secure you want the database to be. Now,when you deploy the WAR file of the Grails application to Tomcat,it will use the embedded H2 database for production,saving the file under the Tomcat location. You can also put the DB file anywhere you want,but my goal was to keep the whole application (Tomcat + Grails) together so I could provide it as a preconfigured Zip file. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |