-->
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.  [ 2 posts ] 
Author Message
 Post subject: java.sql.SQLException while buildSessionFactory() on MYSQL 5
PostPosted: Fri Sep 29, 2006 4:22 am 
Newbie

Joined: Wed Jun 07, 2006 10:31 am
Posts: 3
Location: pune, india
Hibernate version: 3.1.1

Mapping documents:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration
PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory name="SFN" >

<!-- local connection properties -->
<property name="hibernate.connection.url">jdbc:mysql://localhost/bfl</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.username">suhasw</property>
<property name="hibernate.connection.password">ram681</property>
<!-- property name="hibernate.connection.pool_size"></property -->

<!-- dialect for MySQL -->
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>

<property name="hibernate.show_sql">true</property>
<!-- <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
-->
<mapping resource="Post.hbm.xml"/>
<mapping resource="Topic.hbm.xml"/>
<mapping resource="User.hbm.xml"/>

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

Code between sessionFactory.openSession() and session.close():

cfg = new Configuration();
System.out.println( "created configuration successfully" );
cfg.addClass(discussion.User.class)
.addClass(discussion.Topic.class)
.addClass(discussion.Post.class);
System.out.println( "Added Classes successfully" );
//Problem code 2 lines
factory= cfg.buildSessionFactory();
System.out.println( "created session factory" );

OR

cfg = new Configuration();
System.out.println( "created configuration object successfully" );
cfg.configure( "hibernate.cfg.xml" );
System.out.println( "filled configuration object successfully" );
factory= cfg.buildSessionFactory();
System.out.println( "created session factory" );


Full stack trace of any exception that occurs:

Name and version of the database you are using: My SQL 5.0 with Connector/J 5.0.3
all rights give to RDBMS user 'suhasw' on relvant database in MYSQL

The generated SQL (show_sql=true):

Sep 28, 2006 3:57:01 PM org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.1.3
Sep 28, 2006 3:57:01 PM org.hibernate.cfg.Environment <clinit>
INFO: loaded properties from resource hibernate.properties: {hibernate.connection.username=suhasw , hibertate.connection.password=ram681, hibernate.cglib.use_reflection_optimizer=true, hibernate.dialect=org.hibernate.dialect.MySQLDialect, hibernate.show_sql=true, hibernate.connection.url=jdbc:mysql://localhost/bfl, hibernate.connection.driver_class=com.mysql.jdbc.Driver}
Sep 28, 2006 3:57:01 PM org.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
Sep 28, 2006 3:57:01 PM org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
created configuration successfully
Sep 28, 2006 3:57:01 PM org.hibernate.cfg.Configuration addClass
INFO: Reading mappings from resource: discussion/User.hbm.xml
Sep 28, 2006 3:57:01 PM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: discussion.User -> users
Sep 28, 2006 3:57:01 PM org.hibernate.cfg.Configuration addClass
INFO: Reading mappings from resource: discussion/Topic.hbm.xml
Sep 28, 2006 3:57:02 PM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: discussion.Topic -> topics
Sep 28, 2006 3:57:02 PM org.hibernate.cfg.Configuration addClass
INFO: Reading mappings from resource: discussion/Post.hbm.xml
Sep 28, 2006 3:57:02 PM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: discussion.Post -> posts
Added Classes successfully
Sep 28, 2006 3:57:02 PM org.hibernate.cfg.HbmBinder bindCollectionSecondPass
INFO: Mapping collection: discussion.Topic.posts -> posts
Sep 28, 2006 3:57:02 PM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
Sep 28, 2006 3:57:02 PM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 20
Sep 28, 2006 3:57:02 PM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: autocommit mode: false
Sep 28, 2006 3:57:02 PM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/bfl
Sep 28, 2006 3:57:02 PM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=suhasw }
Sep 28, 2006 3:57:02 PM org.hibernate.cfg.SettingsFactory buildSettings
WARNING: Could not obtain connection metadata
java.sql.SQLException: Access denied for user 'suhasw '@'localhost' (using password: NO)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:946)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2870)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:812)
at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:3269)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1182)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:2644)
at com.mysql.jdbc.Connection.<init>(Connection.java:1531)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
at java.sql.DriverManager.getConnection(DriverManager.java:525)
at java.sql.DriverManager.getConnection(DriverManager.java:140)
at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:72)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1881)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1174)
at discussion.BoardManager.<init>(BoardManager.java:24)
at discussion.BoardManager.main(BoardManager.java:138)
Sep 28, 2006 3:57:02 PM org.hibernate.dialect.Dialect <init>
INFO: Using dialect: org.hibernate.dialect.MySQLDialect
Sep 28, 2006 3:57:02 PM org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
INFO: Using default transaction strategy (direct JDBC transactions)
Sep 28, 2006 3:57:02 PM org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
Sep 28, 2006 3:57:02 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic flush during beforeCompletion(): disabled
Sep 28, 2006 3:57:02 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic session close at end of transaction: disabled
Sep 28, 2006 3:57:02 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Scrollable result sets: disabled
Sep 28, 2006 3:57:02 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC3 getGeneratedKeys(): disabled
Sep 28, 2006 3:57:02 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Connection release mode: auto
Sep 28, 2006 3:57:02 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Maximum outer join fetch depth: 2
Sep 28, 2006 3:57:02 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default batch fetch size: 1
Sep 28, 2006 3:57:02 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Generate SQL with comments: disabled
Sep 28, 2006 3:57:02 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL updates by primary key: disabled
Sep 28, 2006 3:57:02 PM org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory
INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
Sep 28, 2006 3:57:02 PM org.hibernate.hql.ast.ASTQueryTranslatorFactory <init>
INFO: Using ASTQueryTranslatorFactory
Sep 28, 2006 3:57:02 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {}
Sep 28, 2006 3:57:02 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Second-level cache: enabled
Sep 28, 2006 3:57:02 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query cache: disabled
Sep 28, 2006 3:57:02 PM org.hibernate.cfg.SettingsFactory createCacheProvider
INFO: Cache provider: org.hibernate.cache.EhCacheProvider
Exception in thread "main" java.lang.NoClassDefFoundError: net/sf/ehcache/CacheException
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2328)
at java.lang.Class.getConstructor0(Class.java:2640)
at java.lang.Class.newInstance0(Class.java:321)
at java.lang.Class.newInstance(Class.java:303)
at org.hibernate.cfg.SettingsFactory.createCacheProvider(SettingsFactory.java:327)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:219)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1881)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1174)
at discussion.BoardManager.<init>(BoardManager.java:24)
at discussion.BoardManager.main(BoardManager.java:138)


Debug level Hibernate log excerpt: ???
log4j.logger.org.hibernate=DEBUG, stdout is on in log4j.properties
But above is the only code I got as warnign so far.

Problems with Session and transaction handling?


Top
 Profile  
 
 Post subject: Interesting Development on the same topic
PostPosted: Fri Sep 29, 2006 3:09 pm 
Newbie

Joined: Wed Jun 07, 2006 10:31 am
Posts: 3
Location: pune, india
I am using hibernate.cfg.xml and then using only the code that configures the cfg using hibernate.cfg.xml file. It works in both connector/J versions. But it is giving me following exception now, I am working on that :-)

:
:
:
filled configuration object successfully
Sep 30, 2006 12:31:17 AM org.hibernate.cfg.HbmBinder bindCollectionSecondPass
INFO: Mapping collection: discussion.Topic.posts -> posts
Sep 30, 2006 12:31:17 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
Sep 30, 2006 12:31:17 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 20
Sep 30, 2006 12:31:17 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: autocommit mode: false
Sep 30, 2006 12:31:17 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/bfl
Sep 30, 2006 12:31:17 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=suhasw, password=****}
Sep 30, 2006 12:31:18 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: RDBMS: MySQL, version: 5.0.24-community-nt
Sep 30, 2006 12:31:18 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.0.3 ( $Date: 2006-07-26 17:26:47 +0200 (Wed, 26 Jul 2006) $, $Revision: 5553 $ )
Sep 30, 2006 12:31:18 AM org.hibernate.dialect.Dialect <init>
INFO: Using dialect: org.hibernate.dialect.MySQLDialect
Sep 30, 2006 12:31:18 AM org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
INFO: Using default transaction strategy (direct JDBC transactions)
Sep 30, 2006 12:31:18 AM org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
Sep 30, 2006 12:31:18 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic flush during beforeCompletion(): disabled
Sep 30, 2006 12:31:18 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic session close at end of transaction: disabled
Sep 30, 2006 12:31:18 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch size: 15
Sep 30, 2006 12:31:18 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch updates for versioned data: disabled
Sep 30, 2006 12:31:18 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Scrollable result sets: enabled
Sep 30, 2006 12:31:18 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC3 getGeneratedKeys(): enabled
Sep 30, 2006 12:31:18 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Connection release mode: auto
Sep 30, 2006 12:31:18 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Maximum outer join fetch depth: 2
Sep 30, 2006 12:31:18 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default batch fetch size: 1
Sep 30, 2006 12:31:18 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Generate SQL with comments: disabled
Sep 30, 2006 12:31:18 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL updates by primary key: disabled
Sep 30, 2006 12:31:18 AM org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory
INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
Sep 30, 2006 12:31:18 AM org.hibernate.hql.ast.ASTQueryTranslatorFactory <init>
INFO: Using ASTQueryTranslatorFactory
Sep 30, 2006 12:31:18 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {}
Sep 30, 2006 12:31:18 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Second-level cache: enabled
Sep 30, 2006 12:31:18 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query cache: disabled
Sep 30, 2006 12:31:18 AM org.hibernate.cfg.SettingsFactory createCacheProvider
INFO: Cache provider: org.hibernate.cache.NoCacheProvider
Sep 30, 2006 12:31:18 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Optimize cache for minimal puts: disabled
Sep 30, 2006 12:31:18 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Structured second-level cache entries: disabled
Sep 30, 2006 12:31:18 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Echoing all SQL to stdout
Sep 30, 2006 12:31:18 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Statistics: disabled
Sep 30, 2006 12:31:18 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Deleted entity synthetic identifier rollback: disabled
Sep 30, 2006 12:31:18 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default entity-mode: pojo
Sep 30, 2006 12:31:18 AM org.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
Exception in thread "main" java.lang.NoClassDefFoundError
at org.hibernate.tuple.EntityMetamodel.class$(EntityMetamodel.java:41)
at org.hibernate.tuple.EntityMetamodel.<init>(EntityMetamodel.java:122)
at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:412)
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:108)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:216)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1176)
at discussion.BoardManager.<init>(BoardManager.java:32)
at discussion.BoardManager.main(BoardManager.java:135)
Caused by: java.lang.ClassNotFoundException: net.sf.cglib.transform.impl.InterceptFieldEnabled
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
... 9 more


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.