-->
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: Hibernate and tomcat 5.0
PostPosted: Mon Aug 22, 2005 5:08 pm 
Newbie

Joined: Fri Aug 19, 2005 12:48 pm
Posts: 1
I am trying to develop an application using Hibernate and Tomcat5.0.
What i am doing is
1.setting up the datasource in server.xml file in tomcat5.0 all the context variables etc.
2. trying to create a hibernate.cfg.xml file with "Use JNDI datasource" option in MyEclipseIDE.

I am getting an error "no initialization context"
exception raised is...javax.naming.NoInitialContextException: Cannot instantiate class: org.apache.commons.dbc
p.BasicDataSourceFactory [Root exception is java.lang.ClassCastException]


If i use the same server.xml file and "Use JDBC driver" option for hibernate.cfg.xml file i am able to connect to the database and retrieve the information, but with JNDI i am not able to retrieve. Can please somebody help me from this problem.

and also i tried the same server.xml file with a jsp file having the call for initialcontext code like this below, it works fine i am able to get the data but only with hibernate i am not able to get the data. Please help.

Context ctx = new InitialContext();
if(ctx == null )
throw new Exception("Boom - No Context");

DataSource ds =
(DataSource)ctx.lookup(
"java:comp/env/jdbc/TestDB");

if (ds != null) {
Connection conn = ds.getConnection();

if(conn != null) {
//foo = "Got Connection "+conn.toString();
Statement stmt = conn.createStatement();
ResultSet rst =
stmt.executeQuery(
"select department from job_postings_new");
while(rst.next()) {
out.println(rst.getString(1));
}
conn.close();}}

Thanks in Advance.
[/b]


Top
 Profile  
 
 Post subject: Hope this link will help
PostPosted: Mon Aug 22, 2005 5:49 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
http://forums.devshed.com/archive/t-120081

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


Top
 Profile  
 
 Post subject: tomcat+hibernate
PostPosted: Wed Aug 24, 2005 1:22 am 
Newbie

Joined: Tue Aug 23, 2005 12:52 am
Posts: 10
Hi

You can write u r server.xml like this and dont forgot to copy jta.jar in u r classpath.

<Resource name="jdbc/crm"
auth="Container" type="javax.sql.DataSource"
factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
user="root"
password="457yuuio"
driverClassName="org.gjt.mm.mysql.Driver"
url="jdbc:mysql://localhost/crm?user=root&amp;password=457yuuio"
maxWait="-1" removeAbandoned="true" removeAbandonedTimeout="3"
logAbandoned="false"/>

may be this will help u.


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.