Hibernate tools driver issue


(Ed Dunn) #1

First of all I posted this over at stackoverflow

https://stackoverflow.com/questions/48587395/hibernate-tools-with-gradle-jdbc-error

I am trying to run ant hibernate tools from gradle with little success. When compiling I get the following error :

[ant:hibernatetool] An exception occurred while running exporter #2:hbm2ddl (Generates database schema)
[ant:hibernatetool] To get the full stack trace run ant with -verbose
[ant:hibernatetool] org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
[ant:hibernatetool] org.hibernate.exception.JDBCConnectionException: Error calling DriverManager#getConnection
java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306

I am sure that I am loading the mysql-connector into the classpath (as I have printed out the classpath to confirm this).

Here is the code I am trying to execute.

configurations {
    hibtools
}

dependencies {
    hibtools "org.hibernate:hibernate-tools:5.2.3.Final"
    hibtools "org.hibernate:hibernate-core:$hibernateVersion"
    hibtools "org.hibernate:hibernate-c3p0:$hibernateVersion"
    hibtools "org.hibernate.common:hibernate-commons-annotations:5.0.1.Final"
    hibtools "org.hibernate:hibernate-entitymanager:$hibernateVersion"
    hibtools group: 'org.dom4j', name: 'dom4j', version: '2.1.0'

    hibtools group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.25'
    hibtools group: 'org.slf4j', name: 'jcl-over-slf4j', version: '1.7.25'
    hibtools 'mysql:mysql-connector-java:5.1.10'
    hibtools group: 'org.springframework.security', name: 'spring-security-core', version: '4.1.5.RELEASE'
    hibtools group: 'org.springframework', name: 'spring-tx', version: '4.1.5.RELEASE'
    hibtools group: 'commons-codec', name: 'commons-codec', version: '1.11'
    hibtools "log4j:log4j:1.2.17"
    hibtools fileTree(dir: "${projectDir}/compsciBuild/lib", include: "**/*.jar")
    hibtools fileTree(dir: "${projectDir}/lib", include: "**/*.jar")
}

task createdb(dependsOn: copy_c3p0){
    doLast{
        ant.taskdef(name: 'hibernatetool', classname: 'org.hibernate.tool.ant.HibernateToolTask', classpath: configurations.hibtools.asPath + classes_dir)
        ant.hibernatetool(destdir: '${classes_dir}') {
            ant.annotationconfiguration(configurationfile: "${classes_dir}/hibernate.cfg.xml")
            ant.hbm2ddl(drop: 'true')
        }
    }
}

Any help would be greatly appreciated