Quantcast
Channel: Spring Community Forums - Data
Viewing all articles
Browse latest Browse all 297

SQL connections

$
0
0
Greetings,

I'm wondering what the best way is to create and maintain a SQL connection using an Oracle database and groovy.sql.Sql. I'm going to be executing some scripts from the command line for now (Unix and Windows) so will pass in the needed database logon credentials.

Right now I have three services (public classes). The main service calls the other two. All 3 perform SQL using sql.call and sql.execute statements. I set up my initial SQL connection like so:

def sql = Sql.newInstance(url, username, password, driver)

But then I find that I have to pass this sql object to the methods I'm calling from the other services otherwise these methods do not understand what sql.call is. Seems that there should be a better way of doing this. Do I really need to pass the sql connection to every method I call? I have done a lot of searching on this and for some reason cannot find the answer. Thanks!

Tom

Viewing all articles
Browse latest Browse all 297

Trending Articles