#1472 How to load a jar at runtime

rahulpilani Sun 3 Apr 2011

I am new to Fantom, so please bear with me. I am trying to build a db browser application in Fantom, and for that I need to allow the user to load the jdbc driver for the db that they want to connect to.

Is it possible in Fantom to load a JDBC driver at runtime? I know it uses JDBC under the cover for the SqlConn and related classes, but it seems that the drivers need to be present at startup. Dynamic loading of jars is not supported?

brian Mon 4 Apr 2011

I am not completely sure what you mean by "dynamic loading of jars" - are you talking about writing your own ClassLoaders?

The way you initial a JDBC driver in Fantom is covered in sql docs. Take a look at that and see if it solves your problem.

rahulpilani Sun 24 Apr 2011

I did mean writing or using a classloader to load a jar at runtime. Since the licenses of some jdbc drivers don't allow distribution, it's best to let the users download them and load them.

brian Sun 24 Apr 2011

If you want to your users to download a JDBC driver, you just need to instruct them to place the jar in Java ext directory or Fantom lib/java/ext directory. Then you might need to add a line to etc/sql/config.props.

Login or Signup to reply.