Yes, that sounds right. On Tue, Jan 21, 2020 at 8:52 AM Jason S <jst...@gmail.com> wrote:
> Maybe > > groovy.grape.Grape.grab(classLoader: ClassLoader.getSystemClassLoader(), > group: 'com.oracle.ojdbc', module: 'ojdbc8', version: '19.3.0.0') > > ... though that could fail with a Security manager exception. > > On Mon, Jan 20, 2020 at 4:46 PM Nelson, Erick <erick.nel...@hdsupply.com> > wrote: > >> Ya, ive tried that, it’s the grabconfig systemClassLoader=true that is >> making this difficult for me (I think). >> >> I get the usual error as if I did not put the grab config in the @grab >> annotation … >> >> >> >> java.sql.SQLException: No suitable driver found for jdbc:oracle:thin:@// >> ecprd4.hdsupply.net:1521/ecprd4 >> >> >> >> I’m still going through groovy.grape.GrabAnnotationTransformation to see >> how it is done there. >> >> >> >> Erick Nelson >> >> Senior Developer – IT >> >> HD Supply Facilities Maintenance >> >> (858) 740-6523 >> >> >> >> >> >> *From: *Paul King <pa...@asert.com.au> >> *Reply-To: *"users@groovy.apache.org" <users@groovy.apache.org>, " >> pa...@asert.com.au" <pa...@asert.com.au> >> *Date: *Monday, January 20, 2020 at 2:32 PM >> *To: *"users@groovy.apache.org" <users@groovy.apache.org> >> *Subject: *Re: Convert @Grab to Grape.grab ? >> >> >> >> It's certainly possible since that is what the compiler does. The >> compiler goes the extra step and adds the jar onto the classpath at >> compilation time as well but you might not need that. >> >> >> >> From a script you'd do something like: >> groovy.grape.Grape.grab(classLoader: getClass().classLoader, group: >> 'com.oracle.ojdbc', module: 'ojdbc8', version: '19.3.0.0') >> >> >> >> Depending on your context you might need to get the classloader in >> a slightly different way. >> >> >> >> Cheers, Paul. >> >> >> >> >> >> >> >> On Tue, Jan 21, 2020 at 6:36 AM Nelson, Erick <erick.nel...@hdsupply.com> >> wrote: >> >> Is it possible to convert a Grab annotation to a Grapes.grab call? >> >> >> >> Example: >> >> Convert this… >> >> >> >> @Grapes([ >> >> @GrabConfig(systemClassLoader=true), >> >> @Grab('com.oracle:ojdbc6:11.2.0.1.0'), >> >> ]) >> >> import groovy.sql.Sql >> >> >> >> to this… >> >> >> >> groovy.grape.Grape.grab(group:'com.oracle', module:'ojdbc6', >> version:'11.2.0.1.0') >> >> >> >> >> >> I’m assuming I’d need to add map entries for classLoader: and refObject: >> but I’m not sure how to assemble these if needed. >> >> >> >> I’d like to put the Grapes.grab call in my compiled library. Is this >> even possible? >> >> >> >> My library connects to oracle like this… >> >> >> >> Sql.withInstanceOracle(user:'tauser03',name:'ecprd4') { sql -> } >> >> >> >> The static method withInstanceOracle is a metaClass method that under the >> hood calls this… >> >> >> >> >> >> *static* Sql newInstance (Map map) { >> >> // groovy.grape.Grape.grab(group:'com.oracle', module:'ojdbc6', >> version:'11.2.0.1.0') >> >> Map connectionMap = *buildConnectionMap*(map) >> >> *log*.info "connecting to [${connectionMap.url}] as [${ >> connectionMap.user}]" >> >> Sql sql = Sql.*newInstance*(connectionMap) >> >> sql.connection.setAutoCommit(*false*) >> >> sql >> >> } >> >> >> >> In my Oracle class. >> >>