-->
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: HIbernate tool for artifect generation
PostPosted: Fri Oct 14, 2005 7:59 am 
Newbie

Joined: Fri Oct 14, 2005 7:52 am
Posts: 9
Location: delhi
Hi all
i m using eclipse 3.1 and hibernate too from hibernate.org but at artifect generation timt gives this error org.hibernate.HibernateException:Could not find datasource
What may be the cause


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 14, 2005 8:32 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
that you are using a datasource in your hibernate.cfg.xml which for obvious reasons is not available from inside eclipse.

use a DriverManagerConnectionProvider to allow hibernate to get that connection from within hibernate

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Hibernate tool artifect error
PostPosted: Fri Oct 14, 2005 8:44 am 
Newbie

Joined: Fri Oct 14, 2005 7:52 am
Posts: 9
Location: delhi
my coding for connection pooling is as :
<Context path="/HibernatePrj" reloadable="true" docBase="E:\Projects\HibernatePrj" workDir="E:\Projects\HiberPrj\work" >
<Resource name="jdbc/hiberprj" scope="shareable" type="javax.sql.DataSource" auth="container"/>
<ResourceParams name="jdbc/hiberprj">
<parameter><name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>

<parameter>
<name>url</name>
<value>jdbc:mysql://192.168.10.1:3306/hibertest?autoReconnect=true</value>
</parameter>

<parameter>
<name>driverClassName</name>
<value>com.mysql.jdbc.Driver</value>
</parameter>

<parameter>
<name>username</name>
<value>test</value>
</parameter>

<parameter>
<name>password</name>
<value>test</value>
</parameter>

<parameter>
<name>maxActive</name>
<value>100</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>20</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>10000</value>
</parameter>


</ResourceParams>
</Context>
And in web.xml i put like this
<resource-ref>
<description> DB Connection pooling</description>
<res-ref-name>jdbc/hiberprj</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<servlet>
<servlet-name>pool</servlet-name>
<servlet-class>pkg.DbConTest</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>pool</servlet-name>
<url-pattern>/test</url-pattern>
</servlet-mapping>
But from other application ( in a servlet i m using same JNDI ) and it is working and showing data from databse when i execute servlet ,

However may u elaborate ur idea of DriverManagerConnectionProvider as i m new to hibernate.

max wrote:
that you are using a datasource in your hibernate.cfg.xml which for obvious reasons is not available from inside eclipse.

use a DriverManagerConnectionProvider to allow hibernate to get that connection from within hibernate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 14, 2005 8:54 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
when you use hibernate from inside eclipse you are not running inside any servlet container etc.

Thus you just need to have a hibernate.cfg.xml that specifies the related connection parameters (the following is an example for hsql)

hibernate.dialect org.hibernate.dialect.HSQLDialect
hibernate.connection.driver_class org.hsqldb.jdbcDriver
hibernate.connection.url jdbc:hsqldb:.


The hibernate.connection.provider_class should either be empty or set to org.hibernate.connection.DriverManagerConnectionProvider

_________________
Max
Don't forget to rate


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.