I used to have a Java Class in my Grails app, but I needed to get a connection from DataSource.groovy
so I passed it to a Groovy Class, and I made it getting the Context Application. But How can I connect to that that Datasource with this code?:
def dataSource = ctx.getBean('dataSource_Executer') // auto injected and referenced to a datasource
Connection conn = null;
Statement stmt = null;
Class.forName('driver');
conn = DriverManager.getConnection(dataSource);// Here it's the trouble
I need it like this because I need the Metadata of the result query like this:
stmt = conn.createStatement();
def rs = stmt.executeQuery('query');
def rsmd = rs.getMetaData();
num = rsmd.getColumnCount();
and control it with a While:
while(rs.next()){..........}