Hibernate cfg.xml Error

package com.myhibernate;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );

Configuration configuration = new Configuration();
configuration.configure();
SessionFactory sessionFactory = configuration.buildSessionFactory();

System.out.println(sessionFactory);
}
}
package com.myhibernate;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );

Configuration configuration = new Configuration();
configuration.configure();
SessionFactory sessionFactory = configuration.buildSessionFactory();

System.out.println(sessionFactory);
}
}
No description
No description
64 Replies
JavaBot
JavaBotā€¢13mo ago
āŒ› This post has been reserved for your question.
Hey @Manish Kumar! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
dan1st
dan1stā€¢13mo ago
well the file needs to be called hibernate.cfg.xml and it needs to be in your resources directory (typically src/main/resources)
Manish Kumar
Manish KumarOPā€¢13mo ago
i haven't resources folder, there is src/main/java i tried this also
dan1st
dan1stā€¢13mo ago
you can create one
Manish Kumar
Manish KumarOPā€¢13mo ago
is it mandetory?
dan1st
dan1stā€¢13mo ago
what?
Manish Kumar
Manish KumarOPā€¢13mo ago
resources pkg
dan1st
dan1stā€¢13mo ago
I think so
Manish Kumar
Manish KumarOPā€¢13mo ago
should i make it root dir?
dan1st
dan1stā€¢13mo ago
well technically you can also change the pom.xml in weird ways just create a src/main/resources directory and reload the Maven project in IJ
Manish Kumar
Manish KumarOPā€¢13mo ago
okk
dan1st
dan1stā€¢13mo ago
and make sure you have your hibernate.cfg.xml in there
Manish Kumar
Manish KumarOPā€¢13mo ago
btw i need a guide do u have 2-3 mints?
dan1st
dan1stā€¢13mo ago
src/main/java -> Java files src/main/resources -> other things that are part of the application maybe if you have questions, just ask
Manish Kumar
Manish KumarOPā€¢13mo ago
have you learnt Spring boot?
dan1st
dan1stā€¢13mo ago
I do know Spring Boot
Manish Kumar
Manish KumarOPā€¢13mo ago
only know? means you haven't made any project etc! ?
dan1st
dan1stā€¢13mo ago
I have a project with it In fact, with a friend, I have written 128 pages for a final school project which was a spring project
Manish Kumar
Manish KumarOPā€¢13mo ago
I need guide I am currently Learning hibernate i have learnt Jdbc , Spring core , Spring Jdbc , 50% of servlet Jsp ( j2ee ) should i learn J2EE fully? should i learn hibernate/ Spring mvc etc. before Spring boot?
dan1st
dan1stā€¢13mo ago
Use Spring with Spring Boot and you can learn most of Hibernate with Spring JPA
Manish Kumar
Manish KumarOPā€¢13mo ago
like i am not feeling well , it's boring without any projects šŸ’€,
dan1st
dan1stā€¢13mo ago
Also J2EE is a name that isn't in use any more. It's Jakarta EE now
Manish Kumar
Manish KumarOPā€¢13mo ago
can u tell me which things i learn directly,
dan1st
dan1stā€¢13mo ago
What do you want to learn?
Manish Kumar
Manish KumarOPā€¢13mo ago
spring boot
dan1st
dan1stā€¢13mo ago
then learn Spring stuff
Manish Kumar
Manish KumarOPā€¢13mo ago
all spring modules?
dan1st
dan1stā€¢13mo ago
well you probably don't need every module
Manish Kumar
Manish KumarOPā€¢13mo ago
Jakarta is required for that? also html CSS šŸ’€
dan1st
dan1stā€¢13mo ago
Spring uses Jakarta EE and Hibernate internally
Manish Kumar
Manish KumarOPā€¢13mo ago
that's i am asking which things i learn before Spring boot
dan1st
dan1stā€¢13mo ago
but it abstracts over it a lot
Manish Kumar
Manish KumarOPā€¢13mo ago
i have knowledge about it
dan1st
dan1stā€¢13mo ago
And you don't need HTML/CSS/JS for Spring directly but if you make a web application with Spring, you'll probably need it
Manish Kumar
Manish KumarOPā€¢13mo ago
ohk ...
dan1st
dan1stā€¢13mo ago
Do you know Maven or Gradle?
Manish Kumar
Manish KumarOPā€¢13mo ago
last question i have Knowledge, it's manage our dependencies like we don't need to add jar file manually
dan1st
dan1stā€¢13mo ago
You should be able to use it
Manish Kumar
Manish KumarOPā€¢13mo ago
.. you haven't give ans for that i will back within 20-30mints bye Give me a good short raodmap pls
dan1st
dan1stā€¢13mo ago
cause I don't know exactly I don't have one but ig if you want to know Spring/Spring Boot, do that
Manish Kumar
Manish KumarOPā€¢13mo ago
error is fix @dan1st | Daniel but new error occurs, i.e. MySQL let me show u
Manish Kumar
Manish KumarOPā€¢13mo ago
No description
Manish Kumar
Manish KumarOPā€¢13mo ago
No description
dan1st
dan1stā€¢13mo ago
well the user you set in your hibernate.cfg.xml cannot access the schema actually, it looks like it wasn't able to use the things in that file oh you used hibernate.connect not hibernate.connection
Manish Kumar
Manish KumarOPā€¢13mo ago
ohk 1s now it's saying ` unable to determi Dialect without jdbc metadata
dan1st
dan1stā€¢13mo ago
Did you change all bibernate.connects to hibernate.connection?
Manish Kumar
Manish KumarOPā€¢13mo ago
solvedd
dan1st
dan1stā€¢13mo ago
Also, please use codeblocks instead of images if possible (for text/code)
Manish Kumar
Manish KumarOPā€¢13mo ago
i was using connect in Dialect, hdm2ddl.autk ok sir next tym ty for your help @dan1st | Daniel new error šŸ„²
WARN: HHH000342: Could not obtain connection to query metadata
java.lang.UnsupportedOperationException: The application must supply JDBC connections
WARN: HHH000342: Could not obtain connection to query metadata
java.lang.UnsupportedOperationException: The application must supply JDBC connections
Feb 24, 2024 9:28:26 PM org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl constructDialect
WARN: HHH90000025: MySQLDialect does not need to be specified explicitly using 'hibernate.dialect' (remove the property setting and it will be selected by default)
Feb 24, 2024 9:28:27 PM org.hibernate.metamodel.internal.EntityInstantiatorPojoStandard resolveConstructor
INFO: HHH000182: No default (no-argument) constructor for class: com.myhibernate.Student (class must be instantiated by Interceptor)
Feb 24, 2024 9:28:28 PM org.hibernate.engine.transaction.jta.platform.internal.JtaPlatformInitiator initiateService
INFO: HHH000489: No JTA platform available (set 'hibernate.transaction.jta.platform' to enable JTA platform integration)
Exception in thread "main" java.lang.UnsupportedOperationException: The application must supply JDBC connections
Feb 24, 2024 9:28:26 PM org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl constructDialect
WARN: HHH90000025: MySQLDialect does not need to be specified explicitly using 'hibernate.dialect' (remove the property setting and it will be selected by default)
Feb 24, 2024 9:28:27 PM org.hibernate.metamodel.internal.EntityInstantiatorPojoStandard resolveConstructor
INFO: HHH000182: No default (no-argument) constructor for class: com.myhibernate.Student (class must be instantiated by Interceptor)
Feb 24, 2024 9:28:28 PM org.hibernate.engine.transaction.jta.platform.internal.JtaPlatformInitiator initiateService
INFO: HHH000489: No JTA platform available (set 'hibernate.transaction.jta.platform' to enable JTA platform integration)
Exception in thread "main" java.lang.UnsupportedOperationException: The application must supply JDBC connections
dan1st
dan1stā€¢13mo ago
ok it seems like com.myhibernate.Student is missing a no-args constructor looks like your connection URL might be wrong in some way
Manish Kumar
Manish KumarOPā€¢13mo ago
i fixed this Error constructor err why what happened?
dan1st
dan1stā€¢13mo ago
Does the myhiber database exist?
Manish Kumar
Manish KumarOPā€¢13mo ago
yes i have create in my terminal and this is still in my front šŸ’€
dan1st
dan1stā€¢13mo ago
What Hibernate version are you using?
Manish Kumar
Manish KumarOPā€¢13mo ago
latest 644*
dan1st
dan1stā€¢13mo ago
Is there more shown in the console? Can you show your hibernate.cfg.xml again? Do you have a persistence.xml?
Manish Kumar
Manish KumarOPā€¢13mo ago
no sure
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration SYSTEM
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connect.driver_class">com.mysql.cj.jdbc.Driver</property>
<property name="hibernate.connect.url">jdbc:mysql://localhost:3306/myhiber</property>
<property name="hibernate.connect.username">username</property>
<property name="hibernate.connect.password">password</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hbm2ddl.auto">update</property>
<property name="show_sql">true</property>

<mapping class="com.myhibernate.Student"/>
</session-factory>

</hibernate-configuration>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration SYSTEM
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connect.driver_class">com.mysql.cj.jdbc.Driver</property>
<property name="hibernate.connect.url">jdbc:mysql://localhost:3306/myhiber</property>
<property name="hibernate.connect.username">username</property>
<property name="hibernate.connect.password">password</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hbm2ddl.auto">update</property>
<property name="show_sql">true</property>

<mapping class="com.myhibernate.Student"/>
</session-factory>

</hibernate-configuration>
mysql version 8.0.36
dan1st
dan1stā€¢13mo ago
Is it connect or connection?
Manish Kumar
Manish KumarOPā€¢13mo ago
connect
dan1st
dan1stā€¢13mo ago
I thought you changed everything to connection? I think it should be hibernate.connection
Manish Kumar
Manish KumarOPā€¢13mo ago
no i had connection first so i changed
dan1st
dan1stā€¢13mo ago
Which error are you getting when using hibernate.connection everywhere?
Manish Kumar
Manish KumarOPā€¢13mo ago
should i use connection? let me again check wtf it's Working šŸ˜ƒšŸ˜ƒ
JavaBot
JavaBotā€¢13mo ago
šŸ’¤ Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.

Did you find this page helpful?