-->
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.  [ 4 posts ] 
Author Message
 Post subject: Not reflected in DB
PostPosted: Fri Jul 09, 2010 4:24 am 
Newbie

Joined: Fri Jul 09, 2010 4:19 am
Posts: 2
Hi all ,

when configuring hibernate in that time all the mappings are taken into sessionfactory but not reflected into database schema . In log it is not showing any exception from mapping but it is not being reflected into mysql database schema . Only one INFO is coming , seems not correct is "8874 [main] INFO org.hibernate.impl.SessionFactoryObjectFactory - Not binding factory to JNDI, no JNDI name configured". please help me..


Top
 Profile  
 
 Post subject: Re: Not reflected in DB
PostPosted: Fri Jul 09, 2010 5:30 am 
Newbie

Joined: Fri Jul 09, 2010 4:19 am
Posts: 2
yes solution is found .. and ans is add a prperty into config file named
<property name="hibernate.connection.autocommit">true</property>


Top
 Profile  
 
 Post subject: Re: Not reflected in DB
PostPosted: Wed Jul 21, 2010 10:35 am 
Newbie

Joined: Tue Jul 20, 2010 1:50 pm
Posts: 3
Hi All,
I am getting an Communications link failure error when connecting to my database, so I changed my hibernate XML file to have autoReconnect=true. Which did not solve the problem.
Then I tried the c3po approach and the problem still persists.
I tried the approach of setting wait time, using select 1 query to test the connection etc.. but did not work.

Now I decided to configure the db using data source. This time I can't make a connection. Hibernate is not read the data source. While creating the connection I am getting an exception that states driver class is ' ' and url = null. I already gave this configuration in the context.xml file under META_INF folder.
I am using Tomcat 6 and mysql as my db.

Here are my configuration files....

hibernate.cfg.xml XML is .....................
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory >
<property name="connection.datasource">java:comp/env/jdbc/mydb</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="current_session_context_class">thread</property>

<mapping resource="path/mytable.hbm.xml"/>
</session-factory>
</hibernate-configuration>


Context XML under META-INF/context.xml of the project is .....................
<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/Myproject">
<resource name="jdbc/mydb"
global="jdbc/mydb"
auth="Container"
type="javax.sql.DataSource"
username="username"
password="password"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/dbname?autoReconnect=true"
maxActive="8"
maxIdle="4"/>
</Context>
(Note: I tried putting the resource contents in tomcat's $CATALINA_HOME/conf/context.xml as well. )



web.xml ....................................
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
...
<resource-ref>
<description>My DB Connection</description>
<res-ref-name>jdbc/mydb</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>

HibernateUtil.java .......................
public class HibernateUtil {
private static final SessionFactory sessionFactory;
static {
try {
// Create the SessionFactory from standard (hibernate.cfg.xml)
sessionFactory = new Configuration().configure().buildSessionFactory();

} catch (Throwable ex) {
throw new ExceptionInInitializerError(ex);
}
}

public static SessionFactory getSessionFactory() {

return sessionFactory;

}
}


I am getting this exception when I do sessionFactory.getSession().


Top
 Profile  
 
 Post subject: Re: Not reflected in DB
PostPosted: Wed Jul 21, 2010 11:18 am 
Newbie

Joined: Tue Jul 20, 2010 1:50 pm
Posts: 3
The exception I am getting is

[2010-07-21 11:11:41,991][org.hibernate.impl.SessionFactoryObjectFactory][DEBUG]::::initializing class SessionFactoryObjectFactory
[2010-07-21 11:11:41,993][org.hibernate.impl.SessionFactoryObjectFactory][DEBUG]::::registered: ff80818129f58f620129f58f63a60000 (unnamed)
[2010-07-21 11:11:41,993][org.hibernate.impl.SessionFactoryObjectFactory][INFO ]::::Not binding factory to JNDI, no JNDI name configured
[2010-07-21 11:11:41,993][org.hibernate.impl.SessionFactoryImpl][DEBUG]::::instantiated session factory
[2010-07-21 11:11:41,996][org.hibernate.impl.SessionFactoryImpl][DEBUG]::::Checking 0 named HQL queries
[2010-07-21 11:11:41,997][org.hibernate.impl.SessionFactoryImpl][DEBUG]::::Checking 0 named SQL queries
[2010-07-21 11:11:42,029][org.hibernate.impl.SessionImpl][DEBUG]::::opened session at timestamp: 12797251020
[2010-07-21 11:11:42,083][org.hibernate.transaction.JDBCTransaction][DEBUG]::::begin
[2010-07-21 11:11:42,084][org.hibernate.jdbc.ConnectionManager][DEBUG]::::opening JDBC connection
[2010-07-21 11:11:42,087][org.hibernate.util.JDBCExceptionReporter][DEBUG]::::Cannot open connection [???]
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1150)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
at org.hibernate.connection.DatasourceConnectionProvider.getConnection(DatasourceConnectionProvider.java:69)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:423)
at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:144)
at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:119)
at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:57)
at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1326)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:301)
at $Proxy0.beginTransaction(Unknown Source)


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