get data out of a mysql database



Hi there,
I've successfully installed mysql on my pc and on my server, grails is using these databases in the development and productive environment.
So far, so good.

On a certain gsp is a javascript that generates a chart using highcharts (see Right now, all the data of my charts are static, the values are saved within in the .js file.

Now, I want to use data from the mysql database. Sadly, I have no idea how to run a query and save the values.

What I have accomplished is: creating a json file from my controller and use it as source for highcharts. The problem: the domain does not contain the values, that I want to show (for example: I have a customer with a name, location etc., but the graph shows some external data, that is not saved within his controller).

Have you any ideas how I could do that?


Staff member
You should format the JSON yourself in your grails controller, then you can pass back anything you like.

Typically I would create a map like

def highchartsData = [ someField: value, anotherField:value ]

then finally rendering it as JSON with

render highchartsData as JSON