War file generated by Grails ignores datasource url

Grails version: 1.1

Tomcat version: 5.5

Problem: The app does not use URL data sources.

It looks like it is using some other data source, but it doesn't seem to be in DB memory as I can see the data persist between sessions.

I even tried to give a non-exclusive database name and the app works fine. By this I mean that I can save data and receive it in the application I cannot figure out where the data is stored !!!

I created a war file using 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

        }

    }

 }  

      

+2


source to share


2 answers


You need to set your production data source as the one that uses grails when creating the 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
}
        }


      

+2


source


What evidence do you see that tells you that Grails is ignoring your data source?

Do you go into MySQL before running Grails to create mydb, add a user with "usr" and "pwd", and GRANT the appropriate permissions? Griles doesn't do this for you.



Once the database exists, Grails will create a schema for you. You must be able to login, use mydb and "show tables" to see the schema.

But first, you must create a database.

0


source







All Articles