1

I have a project in eclipse (indigo) where I access SQL data using Hibernate.

I have set up a couple of classes and used annotations to manually map to the tables. I have added a driver jar file (sqljdbc4.jar) to the build path and entered the path to folder containing _sqljdbc_auth.dll_ as "native library location" under the driver jar file (in order to support integrated security).

I can access the data using JDBC connection to my SQL Server 2012, that uses integrated security and that I have defined in hibernate.cfg.xml.

As the next step, I'd like to generate classes from the remaining SQL tables automatically. So I installed Hibernate tools from JBOSS site and I'm trying to follow through the necessary steps: I've created a console configuration based on my hibernate configuration file. Now in Hibernate perspective of my project I see three items "Configuration", "Session factory" and "Database". In properties of "Configuration" I see my connection url and other settings.

However when I click on "Database" I receive an error org.hibernate.exception.JDBCConnectionException: Getting database metadata that boils down to the Caused by: java.lang.UnsatisfiedLinkError: no sqljdbc_auth in java.library.path

  1. it seems that the tool ignores the project setup - it picks up the jar, but not path to dll, and
  2. I see no way how to add the folder with dll to the java.library.path

I've tried to use set java.library.path using hibernate.properties file and referencing this file in console configuration. This seems to be doing half the job as in "Configuration" item now I can see the folder included in java.library.path. However it does not change anything when I try to click on "Database" or configure a code generation configuration - still no sqljdbc_auth in java.library.path error.

The only workaround I have found so far is to drop my dll in any folder that shows by default in java.library.path. Then I can configure the "code generation configuration" and create the classes. However 64-bit dll in the default path gets loaded and causes conflict for example when I need 32-bit version of it from another application, so I'd rather do it properly and reference as-needed.

Maybe it is possible to add the path under Classpath tab in Console Configuration, but it all looks what it says - "classpath" and say adding my folder to it does not change anything.

I'd like to know how to configure java.library.path correctly for the Hibernate tools. Any ideas? Is it possible?

Guillaume Husta
  • 4,049
  • 33
  • 40
Normunds Kalnberzins
  • 1,213
  • 10
  • 20

1 Answers1

0

I've been through similar problems. In a plain Java project, I could set native library or add a Java VM runtime parameter. With Hibernate Tools, I could just add the sql server jdbc driver (jar file). The only way I've found to make Hibernate Tools recognize the DLL was to add the following line to the "eclipse.ini" file:

-Djava.library.path=C:\Program Files\Microsoft JDBC Driver 4.0 for SQL Server\sqljdbc_4.0\enu\auth\x64

Please try this approach, adjusting it to the DLL location in your machine.

P.S.: I'm using SQL Server Express 2012. Hibernate Tools is now showing the database schema in Eclipse. But I'm very new to using it, so my HQL queries do compile, but I still can't see any result from executing them.

Community
  • 1
  • 1
Jose Tepedino
  • 1,524
  • 15
  • 18