-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: using hibernate with mysql database-unable to open database
PostPosted: Tue Apr 26, 2005 5:54 pm 
Newbie

Joined: Thu Apr 14, 2005 9:58 pm
Posts: 7
Hello friends,
Hibernate version: 3.0.1


Full stack trace of any exception that occurs:
Exception in thread "main" java.lang.ExceptionInInitializerError
at hibernate.simple.Storage.openDatabase(Storage.java:298)


Name and version of the database you are using:
name= simpleperson
version= mysql 4.1


Code where mysql settings are set for hibernate:
Code:
Configuration cfg = new Configuration()
        .addClass( Person.class )
        .setProperty( Environment.POOL_SIZE, "10" )
        .setProperty( Environment.MAX_FETCH_DEPTH, "3" )
        .setProperty( Environment.DIALECT,
                      "org.hibernate.dialect.MySQLDialect" )
      .setProperty( Environment.DIALECT,
                  "org.hibernate.dialect.MySQLInnoDBDialect")
        .setProperty( Environment.DIALECT,
                      "org.hibernate.dialect.MySQLMyISAMDialect")
        .setProperty( "hibernate.connection.username", "PBPUBLIC" )
        .setProperty( "hibernate.connection.password", "PBPUBLIC" )
        .setProperty( "hibernate.connection.url",
                      "jdbc:mysql://localhost/simpleperson" )
        .setProperty( "hibernate.connection.driver_class",
                      "org.gjt.mm.mysql.Driver" ) ;


Code where database is opened:
Code:
private void openDatabase( boolean create )
  {
     try
    {
      Configuration cfg = new Configuration()
        .addClass( Person.class )
        .setProperty( Environment.POOL_SIZE, "10" )
        .setProperty( Environment.MAX_FETCH_DEPTH, "3" )
        .setProperty( Environment.DIALECT,
                      "org.hibernate.dialect.MySQLDialect" )
      .setProperty( Environment.DIALECT,
                  "org.hibernate.dialect.MySQLInnoDBDialect")
        .setProperty( Environment.DIALECT,
                      "org.hibernate.dialect.MySQLMyISAMDialect")
        .setProperty( "hibernate.connection.username", "PBPUBLIC" )
        .setProperty( "hibernate.connection.password", "PBPUBLIC" )
        .setProperty( "hibernate.connection.url",
                      "jdbc:mysql://localhost/simpleperson" )
        .setProperty( "hibernate.connection.driver_class",
                      "org.gjt.mm.mysql.Driver" ) ;         
      if ( create )
        cfg.setProperty( Environment.HBM2DDL_AUTO, "create" ) ;

      sessionFactory = cfg.buildSessionFactory() ;
    }
    catch ( Throwable ex )
    {
      throw new ExceptionInInitializerError( ex ) ;
    }
  }


Can someone tell me where I am going wrong?
Thanks,
Manju


Top
 Profile  
 
 Post subject: AN UPDATE to the error being generated-i tried and failed
PostPosted: Tue Apr 26, 2005 7:44 pm 
Newbie

Joined: Thu Apr 14, 2005 9:58 pm
Posts: 7
Exception Stack Trace:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:111)


This above was the exception shown when i changed the database opening code as follows:
Code:
private void openDatabase( boolean create )
  {
     try
    {
      Configuration cfg = new Configuration();
      cfg.addClass( Person.class );
      cfg.setProperty( Environment.DIALECT,
                      "org.hibernate.dialect.MySQLDialect" );
     cfg.setProperty( Environment.DIALECT,
                  "org.hibernate.dialect.MySQLInnoDBDialect");
      cfg.setProperty( Environment.DIALECT,
                      "org.hibernate.dialect.MySQLMyISAMDialect");
      cfg.setProperty( "hibernate.connection.username", "PBPUBLIC" );
      cfg.setProperty( "hibernate.connection.password", "PBPUBLIC" );
      cfg.setProperty( "hibernate.connection.url",
                      "jdbc:mysql://localhost/simpleperson" );
      cfg.setProperty( "hibernate.connection.driver_class",
                      "org.gjt.mm.mysql.Driver" ) ;
     
     
      if ( create )
        cfg.setProperty( Environment.HBM2DDL_AUTO, "create" ) ;

      sessionFactory = cfg.buildSessionFactory() ;
    }
    catch (MappingException e)
    {
       System.err.println("Mapping Exception" + e.getMessage());
       throw new RuntimeException(e);
    }
    catch (HibernateException e)
    {
       System.err.println("Hibernate Exception" + e.getMessage());
       throw new RuntimeException(e);
    }
    /*catch ( Throwable ex )
    {
      throw new ExceptionInInitializerError( ex ) ;
    }*/
  }


when i debugged and checked the Configuration class, the following line of code is where it is generation error:
Code:
private static Log log = LogFactory.getLog( Configuration.class );


CAN SOMEBODY HELP ME OUT HERE?
--manju


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 27, 2005 1:24 am 
Newbie

Joined: Tue Apr 05, 2005 8:01 am
Posts: 12
Why dont you just take a closer look at the exception. It has a lot to say about the error. You dont have the jakarta common loggins jar file in the class path. If you are a newbie you will get more error like this. Insted of putting on the forum for simple things like this, solve this kind of error urself. Hibernate needs some more jar files which will be found in the lib directory of the hibernate extracted directory. Include which ever is required in the classpath.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.