7 Replies Latest reply: Jul 26, 2010 8:56 AM by darren hartford RSS

Driver Definition/JDBC driver

darren hartford Expert

Hey all,

Has anyone found a good way to install Driver Definition/JDBC drivers via an Eclipse Plugin/update-site approach?  I'm trying to avoid the 'use this specific filepath' as supporting many developers it gets a little silly.

 

Historically, I've been leaning on the DTP Enablement plugins to provide these features, but as you work with the newer Eclipse versions there are unnecessary dependency conflicts coming into play with DTP.

  • 1. Re: Driver Definition/JDBC driver
    Brian Fitzpatrick Apprentice

    Hi Darren...

     

    Couple of things...

     

    First, what "unnecessary dependency conflicts" are you running into with DTP? I ask because I'm on the DTP team at Eclipse and if you create a bugzilla entry for them, we can look into those. And what version of DTP? Helios?

     

    Second, I'm not completely sure of your use case. Are you asking if there's a way to install driver plug-ins into a running Eclipse instance in a method similar to the way you install new server adapters in WTP or new Mylyn Connectors? Or are you asking if there's a way to expose a driver jar in a plug-in and create a driver template that automatically picks up the jar in the plug-in and pre-populates that?

     

    --Fitz

  • 2. Re: Driver Definition/JDBC driver
    darren hartford Expert

    I figured out the DTP issue, I was used to using the database-specific enablements, with 1.7.0-up it seems to be wrapped underneath a single plugin (at least that is what it appears) instead of individual plugins, but doesn't seem to be working like previous setups -- see below.

     

    If you are using the JPA project, hibernate tools project, etc, there is the, under Eclipse->preferences, the Data Management->Connectivity section that lists all jdbc.jar's loaded into the system and the jdbc-url templates ready to go. Once the Data Management/connectivity is setup with those jdbc.jar/templates, all the other tools can now use those references.  Using your words --

     

    "expose a driver jar in a plug-in and create a driver template that automatically picks up the jar in the plug-in and pre-populates"

     

    What I am looking for, whether with DTP or some other plugin, is a way to get all those jdbc.jar's setup, templates setup, exposed through Data Management->Connectivity through some type of plugin approach instead of always browsing through the filesystem to setup the jars.

  • 3. Re: Driver Definition/JDBC driver
    darren hartford Expert

    Hi Brian,

    Is it the intent that the DTP enablement explicitly does *not* supply the JDBC driver, and leaves it to the user on how to add JDBC driver jar?

     

    This seems to be the case, and trying to create a relative-mapping to JDBC driver location on any particular box doesn't seem feasible.

     

    Is the intent that the DTP enablement understand if the JDBC driver is available on the classpath if the JDBC driver is added as a plugin as described something like here:  http://wiki.eclipse.org/Create_and_Export_MySQL_JDBC_driver_bundle ?

  • 4. Re: Driver Definition/JDBC driver
    Brian Fitzpatrick Apprentice

    That's certainly part of the equation - making sure that the driver jar is available on the Eclipse classpath.

     

    But there's another step... Once you have your jar wrapped in a plug-in, you have to tell the driver template where to find it. You can do that with a driver template override...

     

    For example, if I've exposed my derby.jar for a Derby database JDBC driver in plug-in org.eclipse.datatools.derby.wrapper... I can override the jar list of that driver so that it automatically picks it up.

     

    <plugin>
       <extension
             point="org.eclipse.datatools.connectivity.driverExtension">
          <driverTemplateOverride
                jarList="[org.eclipse.datatools.derby.wrapper]/lib/derby.jar"
                priority="1"
                targetId="org.eclipse.datatools.connectivity.db.derby102.genericDriverTemplate">
          </driverTemplateOverride>

              </extension>

    </plugin>

     

    If you want it to automatically add the driver instance the first time the DriverManager is fired up (i.e. whenever you fire up the Data Source Explorer it'll check to see if the default driver instance has been created), you just add createDefault = true like this:

     

    <extension
             point="org.eclipse.datatools.connectivity.driverExtension">
          <driverTemplateOverride
                createDefault="true"
                jarList="[org.eclipse.datatools.derby.wrapper]/lib/derby.jar"
                priority="1"
                targetId="org.eclipse.datatools.connectivity.db.derby102.genericDriverTemplate">
          </driverTemplateOverride>
       </extension>

     

    Hope that helps!

     

    --Fitz

  • 5. Re: Driver Definition/JDBC driver
    darren hartford Expert

    This is sounding very exciting!  (I haven't done plugin work since...3.0, so this would be considered 'new' for the 3.5/3.6 since things have changed since that time!)

     

    It sounds like the extension point "org.eclipse.datatools.connectivity.driverExtension" gets us hooked into DTP/Eclipse Data Management.

     

    The 'magic match' value seems to be this value: "org.eclipse.datatools.connectivity.db.derby102.genericDriverTemplate"

     

    I tried to go through the plugin.xml/plugin.properties in the enablement plugins for the other drivers I want to load (MS SQL, MySQL, postgres, etc), but can't seem to find an equivalent value -- where is a list of those values, or how could one derive them?

  • 6. Re: Driver Definition/JDBC driver
    Brian Fitzpatrick Apprentice

    Easiest way to get the particular values you're looking for is to look at the enablement plug-ins for those databases...

     

    For MySQL, look at org.eclipse.datatools.enablement.mysql in the plugin.xml for the "org.eclipse.datatools.connectivity.driverExtension" extension point. You'll see there are actually multiple driver definitions listed... one per version... 4.0, 4.1, 5.0, 5.1.

     

    In the 5.1 case, the "special sauce" you're looking for is the driver template ID - org.eclipse.datatools.enablement.mysql.5_1.driverTemplate. The rest stays the same like the Derby case.

     

    For MS SQL, look at the org.eclipse.datatools.enablement.msft.sqlserver plug-in.

     

    For postgres, look at org.eclipse.datatools.enablement.postgresql...

     

    And so on.

     

    You'll have to override all the templates you're interested in (including the various vendor/version combinations) to include appropriate jars where they're needed.

     

    Hope that helps!

     

    --Fitz

  • 7. Re: Driver Definition/JDBC driver
    darren hartford Expert

    Thread carried over to:  http://www.eclipse.org/forums/index.php?t=msg&th=171931&start=0

     

    Made some progess there.