[jboss-as7-dev] problem with the classloader, not able to load a JDBC driver
Jason T. Greene
jason.greene at redhat.com
Tue Jul 31 17:31:55 EDT 2012
I can't remember if I replied to this one or not, but a better solution
is to use the Driver class directly. We should avoid sticking random
things in the global registry which might even end up containing
conflicting values.
On 7/24/12 7:53 AM, Flemming Harms wrote:
> Thanks!
>
> I had to do one more thing to make it work with the module class loader,
> since the database driver was loaded in it's own class loader and it was
> not known to the current class loader I had to find a way to make it
> available
>
> I solve it by wrapping the driver in my own class and register the
> driver to the DriverManager
>
> Like this :
> DriverManager.registerDriver(new DatabaseDriverWrapper(driver));
> DriverManager.getConnection(url, user, password);
>
> 2012/7/23 Tomaž Cerar <tomaz.cerar at gmail.com <mailto:tomaz.cerar at gmail.com>>
>
>
>
> On Mon, Jul 23, 2012 at 5:58 PM, Jason T. Greene
> <jason.greene at redhat.com <mailto:jason.greene at redhat.com>> wrote:
>
> On 7/23/12 10:51 AM, Jesper Pedersen wrote:
> > On 07/23/2012 11:42 AM, Flemming Harms wrote:
> >> I found a solution to my problem. Had to update the xsd
> schema with an
> >> extra attribute "module" and then user need pack his JDBC
> driver as module.
> >>
> >> I use the code below to load the model and the driver class.
> >>
> >> Class<?> driverClass =
> >>
> Module.loadClassFromCallerModuleLoader(ModuleIdentifier.fromString(moduleName),
> >> driver);
> >> driverClass.newInstance();
> >>
> >> <outbound-connections>
> >> <database>
> >> <connection module="com.h2database.h2"
> >> driver="org.h2.jdbcx.JdbcDataSource" name="db"
> >> url="jdbc:h2:/tmp/test;DB_CLOSE_DELAY=-1" username="sa"
> password=""
> >> min-pool-size="10" max-pool-size="20" />
> >> </database>
> >> </outbound-connections>
> >>
> >> Does it make sense?
> >
> > The -ds.xml functionality uses the module through the
> <driver> tag, so
> > this would be similar.
> >
> > Things to watch out for is of course the password attribute -
> it should
> > at least support the vault mechanism I would say.
>
> If you make the attribute definition have expressions=true, it will
> automatically enable vault support.
>
> given that you use AD.parseAndSetParameter() when parsing and
> setting field and AD.resolveModelAttribute() when getting data from
> model
>
> --
> Jason T. Greene
> JBoss AS Lead / EAP Platform Architect
> JBoss, a division of Red Hat
> _______________________________________________
> jboss-as7-dev mailing list
> jboss-as7-dev at lists.jboss.org <mailto:jboss-as7-dev at lists.jboss.org>
> https://lists.jboss.org/mailman/listinfo/jboss-as7-dev
>
>
>
> _______________________________________________
> jboss-as7-dev mailing list
> jboss-as7-dev at lists.jboss.org <mailto:jboss-as7-dev at lists.jboss.org>
> https://lists.jboss.org/mailman/listinfo/jboss-as7-dev
>
>
>
>
> _______________________________________________
> jboss-as7-dev mailing list
> jboss-as7-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/jboss-as7-dev
>
--
Jason T. Greene
JBoss AS Lead / EAP Platform Architect
JBoss, a division of Red Hat
More information about the jboss-as7-dev
mailing list