Bugfix: database-parameters for connection were not taken from properties
authorKai Moritz <kai@coolibri.de>
Tue, 15 Jan 2013 08:09:05 +0000 (09:09 +0100)
committerKai Moritz <kai@coolibri.de>
Tue, 15 Jan 2013 20:41:05 +0000 (21:41 +0100)
The hibernate-propertiesfile was read and used for the configuration of
the SchemaExport-class, but the database-parameters from these source were
ignored, when the database-connection was opened.

src/main/java/de/juplo/plugins/hibernate4/Hbm2DdlMojo.java

index e7aa154..7cae92f 100644 (file)
@@ -527,17 +527,28 @@ public class Hbm2DdlMojo extends AbstractMojo
             case CREATE:
             case DROP:
             case BOTH:
-              Class driverClass = classLoader.loadClass(driverClassName);
+              Class driverClass = classLoader.loadClass(properties.getProperty(DRIVER_CLASS));
               getLog().debug("Registering JDBC-driver " + driverClass.getName());
               DriverManager.registerDriver(new DriverProxy((Driver)driverClass.newInstance()));
-              getLog().debug("Opening JDBC-connection to " + url + " as " + username + " with password " + password);
-              connection = DriverManager.getConnection(url, username, password);
+              getLog().debug(
+                  "Opening JDBC-connection to "
+                  + properties.getProperty(URL)
+                  + " as "
+                  + properties.getProperty(USERNAME)
+                  + " with password "
+                  + properties.getProperty(PASSWORD)
+                  );
+              connection = DriverManager.getConnection(
+                  properties.getProperty(URL),
+                  properties.getProperty(USERNAME),
+                  properties.getProperty(PASSWORD)
+                  );
           }
       }
     }
     catch (ClassNotFoundException e)
     {
-      getLog().error("Dependency for driver-class " + driverClassName + " is missing!");
+      getLog().error("Dependency for driver-class " + properties.getProperty(DRIVER_CLASS) + " is missing!");
       throw new MojoExecutionException(e.getMessage());
     }
     catch (Exception e)