views:

385

answers:

2

Grails version :1.1

Tomcat version: 5.5

The problem: The application doesn't use the URL data sources.

It seems like - it is using some other data source- but it doesn't seem to be in memory DB- since I can see the data persisted between sessions.

I have even tried giving a non -existant database name -and the application works fine. By that I mean that I am able to persist the data and fetch it fine- in the application I am unable to figure out where the data is getting persisted !!!

I generated the war file using the command- grails war

This is how the dataSource config looks like

dataSource {

pooled = true

driverClassName = "com.mysql.jdbc.Driver"

username = "user"

password = "pwd"

}

hibernate {

cache.use_second_level_cache=true

cache.use_query_cache=true

cache.provider_class='com.opensymphony.oscache.hibernate.OSCacheProvider'

}

environments {

production {

 dataSource {

  dbCreate = "create" 

  url = "jdbc:mysql://localhost:3307/mydb?autoReconnect=true"

  dialect = org.hibernate.dialect.MySQL5Dialect

 }

}

}

A: 

What evidence are you looking at that tells you Grails is ignoring your data source?

Did you go into MySQL prior to running Grails to create mydb, add a user with "usr" and "pwd", and GRANT appropriate permissions? Grails doesn't do that for you.

Once the database exists, Grails will create the schema for you. You should be able to log in, use mydb, and "show tables" to see the schema.

But you have to create the database first.

duffymo
1) If I put a non-existant server name- there are no errors- the CRUD works as ususal2) I am using eatj.com to host the application- and I have confirmed that the database schema does exist3) No table has been created . I can try creating the tables myself- but that wont help - since it doesn't seem to use the URL at all
RN
+2  A: 

You need to set a production data source since that's what grails uses when generating a war.


development {

        dataSource {

                dbCreate = "create" 

                url = "jdbc:mysql://localhost:3307/mydb?autoReconnect=true"

                dialect = org.hibernate.dialect.MySQL5Dialect
}
        }

production {

        dataSource {

                dbCreate = "create" 

                url = "jdbc:mysql://localhost:3307/mydb?autoReconnect=true"

                dialect = org.hibernate.dialect.MySQL5Dialect
}
        }

Jared
Sorry that was my typoI have Production set up - same as Developement (In fact test is also the same)
RN
by default Grails uses the 'prod' environment when building a war, if you want to override it you can run 'grails dev war'
Burt Beckwith