-->
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: problem in sessin factory
PostPosted: Wed Sep 20, 2006 1:21 am 
Newbie

Joined: Wed Sep 20, 2006 12:58 am
Posts: 2
Hi i need help regarding session class(client)

in this

SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory(); is not executing..

i am getting no class found exception please find the solution..


package roseindia.tutorial.hibernate;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;


/**
* @author Deepak Kumar
*
* http://www.roseindia.net
* Hibernate example to inset data into Contact table
*/
public class FirstExample {
public static void main(String[] args) {
Session session = null;

try{
// This step will read hibernate.cfg.xml and prepare hibernate for use
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
session =sessionFactory.openSession();
//Create new instance of Contact and set values in it by reading them from form object
System.out.println("Inserting Record");
Contact contact = new Contact();
contact.setId(6);
contact.setFirstName("Deepak");
contact.setLastName("Kumar");
contact.setEmail("deepak_38@yahoo.com");
session.save(contact);
System.out.println("Done");
}catch(Exception e){
System.out.println(e.getMessage());
}finally{
// Actual contact insertion will happen at this step
session.flush();
session.close();

}

}
}

Code between sessionFactory.openSession() and session.close():[/b]



[/list]


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 20, 2006 2:02 am 
Regular
Regular

Joined: Mon May 08, 2006 6:00 am
Posts: 53
Location: India
Pleae post a stack trace, which class its looking for ? Did you set the class path with all Hibernate related jars in it ?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 20, 2006 2:24 am 
Newbie

Joined: Wed Sep 20, 2006 12:58 am
Posts: 2
sudhir0104 wrote:
Pleae post a stack trace, which class its looking for ? Did you set the class path with all Hibernate related jars in it ?



Here in this calss i am getting Null pointer exception..

hi friends..here iam attaching another one..iam getting problem in drivers

import java.sql.DriverManager;

import java.sql.*;



public class Test {

public static void main(String []arg){

try{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

}

catch(Exception e){

System.out.println("Exception1");

}

try{

Connection con = DriverManager.getConnection("jdbc:oracle:thin:@calv4c02:1521:fuego", "admin1", "password");

if(con!=null)

{

System.out.println("Success");

}

else

{

System.out.println("Fail");

}

}

catch(Exception e)

{

e.printStackTrace();

}

}

java.sql.SQLException: No suitable driver

at java.sql.DriverManager.getConnection(DriverManager.java:532)

at java.sql.DriverManager.getConnection(DriverManager.java:171)

at Test.main(Test.java:13)


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.