0

I am new to hibernate. Using version 4.2.2 with mysql 4. I m getting the same error. I dont know what is happening help me.

hibernate.cfg.xml file

<hibernate-configuration>
<session-factory>

        <property name="hibernate.connction.driver_class">com.mysql.jdbc.Driver</property>
        <property name="hibernate.connction.url">jdbc:mysql://localhost:3306/HibernateDB</property>
        <property name="hibernate.connction.user_name">mysql</property>
        <property name="hibernate.connction.password">mysql</property>


        <property name="dialect">org.hibernate.dialect.MySQLDialect</property>

        <property name="cache.provider_class">org.hibernate.cache.NocacheProvider</property>

        <property name="show_sql">true</property>

        <property name="hibernate.hbm2ddl">create</property>
        <property name="hbm2ddl">craete</property>

        <mapping class="org.shammu.UserDetails" />

</session-factory>
</hibernate-configuration>

UserDetails class

package org.shammu;
import javax.persistence.Entity;
import javax.persistence.Id;

@Entity
public class UserDetails {

@Id
private int userId;
private String userName;
public int getUserId() {
    return userId;
}
public void setUserId(int userId) {
    this.userId = userId;
}
public String getUserName() {
    return userName;
}
public void setUserName(String userName) {
    this.userName = userName;
}
}

And my test class is:

package org.shammu;

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

public class TestClass {

/**
 * @param args
 */
public static void main(String[] args) {
    UserDetails user = new UserDetails();
    user.setUserId(1);
    user.setUserName("Shammu");
    @SuppressWarnings("deprecation")
    SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
    Session session = sessionFactory.openSession();
    session.beginTransaction();

    session.save(user);
    session.getTransaction().commit();

}

}

The console error message is:

Jun 28, 2013 1:02:27 AM org.hibernate.annotations.common.Version <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.2.Final}
Jun 28, 2013 1:02:27 AM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.2.2.Final}
Jun 28, 2013 1:02:27 AM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
Jun 28, 2013 1:02:27 AM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
Jun 28, 2013 1:02:27 AM org.hibernate.cfg.Configuration configure
INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml
Jun 28, 2013 1:02:27 AM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: HHH000040: Configuration resource: /hibernate.cfg.xml
Jun 28, 2013 1:02:27 AM org.hibernate.cfg.Configuration doConfigure
INFO: HHH000041: Configured SessionFactory: null
Jun 28, 2013 1:02:27 AM    org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator initiateService
WARN: HHH000181: No appropriate connection provider encountered, assuming application will be supplying connections
Jun 28, 2013 1:02:27 AM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
Jun 28, 2013 1:02:27 AM org.hibernate.engine.jdbc.internal.LobCreatorBuilder useContextualLobCreation
INFO: HHH000422: Disabling contextual LOB creation as connection was null
Jun 28, 2013 1:02:27 AM  org.hibernate.engine.transaction.internal.TransactionFactoryInitiator initiateService
INFO: HHH000399: Using default transaction strategy (direct JDBC transactions)
Jun 28, 2013 1:02:27 AM org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory <init>
INFO: HHH000397: Using ASTQueryTranslatorFactory
Exception in thread "main" java.lang.UnsupportedOperationException: The application must supply JDBC connections
at  org.hibernate.service.jdbc.connections.internal.UserSuppliedConnectionProviderImpl.getConnection(UserSuppliedConnectionProviderImpl.java:62)
at org.hibernate.internal.AbstractSessionImpl$NonContextualJdbcConnectionAccess.obtainConnection(AbstractSessionImpl.java:292)
at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:214)
at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.getConnection(LogicalConnectionImpl.java:157)
at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.doBegin(JdbcTransaction.java:67)
at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.begin(AbstractTransactionImpl.java:160)
at org.hibernate.internal.SessionImpl.beginTransaction(SessionImpl.java:1426)
at org.shammu.TestClass.main(TestClass.java:19)

I have have included the mysql-connector jar in class path Pls anybody help me..

4
  • Can you please paste the complete stack trace? Commented Jun 27, 2013 at 19:44
  • edited and added the stack trace pls check Commented Jun 27, 2013 at 19:48
  • You've misspelled connection in your four hibernate.connction... properties. Does it help if you fix the spelling? Commented Jun 27, 2013 at 20:16
  • @Luke tnx a lot its solvd... I tried each n evry word for a typo, but couldnt... But u could tnx a lot for help... Commented Jun 27, 2013 at 20:35

1 Answer 1

1

Your configuration file needs a little bit of change:

 <property name="hibernate.connection.username">mysql</property>
 <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>

Looks like hibernate is not able to get the connection to the database. Also make sure that the connection URL that you have given is right along with the database credentials.

Refer to this for the right set of property names:

http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/session-configuration.html

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.