org.hibernate.exception.JDBCConnectionException: Unable to open JDBC Connection for DDL execution

Viewed 1087

I am trying to create tables into the MySQL database using hibernate, but I am facing a problem 'Unable to open JDBC Connection for DDL execution'. I entered a valid connection URL and required jar files but can not able to create a connection with the database. I searched many solutions available for this but none of it work for me. Please tell me what I am doing wrong here.

Hibernate version: hibernate-core-5.4.12.Final

MySQL connector: 8.0.17

DBconn.java

public class Dbconn {

static Connection con=null;
public static Connection connect() throws ClassNotFoundException, SQLException
{
    Class.forName("com.mysql.jdbc.Driver");
    con=DriverManager.getConnection("jdbc:mysql://localhost:3306/maxigodb","root","root");
        //System.out.println("db connected");
    return con;

}
}

HbConnection.java

public class HbConnection {

static Session ses=null;
public static Session getSession() 
{
    StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().configure("hibernate.cfg.xml").build();  

    Metadata meta = new MetadataSources(ssr).getMetadataBuilder().build();  

    SessionFactory factory = meta.getSessionFactoryBuilder().build();  
    ses = factory.openSession();  


    return ses;
}
}

hibernate.cfg.xml

<?xml version="1.0" encoding="UTF-8"?>

    "-//Hibernate/Hibernate Configuration DTD 3.0//EN"

    "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">

    <hibernate-configuration>

    <session-factory>

   <property name=  "hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
    <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/maxigodb</property>
    <property name="hibernate.connection.username">root</property>
    <property name="hibernate.connection.password">root</property>
    <property name="hibernate.dialect">org.hibernate.dialect.MySQL8Dialect</property>

    <property name="hibernate.show_sql">true</property>
    <property name="hbm2ddl.auto">update</property>

    <mapping class="com.maxico.pojo.Login_data"/>
    <mapping class="com.maxico.pojo.Agent_data"/>
    <mapping class="com.maxico.pojo.Hotel_data"/>
    <mapping class="com.maxico.pojo.HotelBooking_Details"/>

</session-factory>

console error

    WARN: HHH030006: Exception occurred when closing the Proxool pool
java.lang.NullPointerException
at org.hibernate.proxool.internal.ProxoolConnectionProvider.stop(ProxoolConnectionProvider.java:233)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.stopService(AbstractServiceRegistryImpl.java:390)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.destroy(AbstractServiceRegistryImpl.java:373)
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.destroy(StandardServiceRegistryImpl.java:129)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.deRegisterChild(AbstractServiceRegistryImpl.java:423)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:468)
at com.maxico.test.HbConnection.getSession(HbConnection.java:20)
at org.apache.jsp.index_jsp._jspService(index_jsp.java:303)
Feb 27, 2020 12:07:39 PM org.hibernate.service.internal.AbstractServiceRegistryImpl stopService

INFO: HHH000369: Error stopping service [class org.hibernate.proxool.internal.ProxoolConnectionProvider]
org.hibernate.HibernateException: HHH030006: Exception occurred when closing the Proxool pool
at org.hibernate.proxool.internal.ProxoolConnectionProvider.stop(ProxoolConnectionProvider.java:241)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.stopService(AbstractServiceRegistryImpl.java:390)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.destroy(AbstractServiceRegistryImpl.java:373)
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.destroy(StandardServiceRegistryImpl.java:129)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.deRegisterChild(AbstractServiceRegistryImpl.java:423)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:468)
at com.maxico.test.HbConnection.getSession(HbConnection.java:20)
at org.apache.jsp.index_jsp._jspService(index_jsp.java:303)

Caused by: java.lang.NullPointerException
at org.hibernate.proxool.internal.ProxoolConnectionProvider.stop(ProxoolConnectionProvider.java:233)
... 39 more

Feb 27, 2020 12:07:39 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [jsp] in context with path [/Maxico] threw exception [An exception occurred processing [index.jsp] at line [182]

181:      Session ses= null;
182:      ses= HbConnection.getSession(); 
183:      System.out.println("Email:" +user);
184:      try {
185:      


Stacktrace:] with root cause
java.sql.SQLException: The url cannot be null
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:660)
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:251)
at org.hibernate.proxool.internal.ProxoolConnectionProvider.getConnection(ProxoolConnectionProvider.java:69)
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcEnvironmentInitiator.java:180)
at org.hibernate.resource.transaction.backend.jdbc.internal.DdlTransactionIsolatorNonJtaImpl.getIsolatedConnection(DdlTransactionIsolatorNonJtaImpl.java:43)
at org.hibernate.tool.schema.extract.internal.DatabaseInformationImpl.getTablesInformation(DatabaseInformationImpl.java:120)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:834)

JAR files

enter image description here

2 Answers

I solve this problem...

This problem is occured because i added two jar files hibernate-proxool-5.4.12.Final and proxool-0.8.3. I removed hibernate-proxool-5.4.12.Final and after this i am able to establish connection to the database.

I think you should delete the quotes :

jdbc:mysql://localhost:3306/maxigodb"

Related