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?
|