IntelliJ Java IDE
The moose likes Object Relational Mapping and the fly likes java.lang.nullpointer Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Object Relational Mapping
Reply Bookmark "java.lang.nullpointer" Watch "java.lang.nullpointer" New topic
Author

java.lang.nullpointer

amrit pursnani
Greenhorn

Joined: Aug 02, 2006
Posts: 9
class ICaptureDbInteract11 {

public static Logger dbLogger=Logger.getLogger(iCaptureService.ICaptureDbInteract.class.getName());

public static void main(String a[])
{
ICaptureDbEO row=null;
Session session=null;
try
{
dbLogger.info("in hibernate function:");
PropertyConfigurator.configure("d:\\log4j.properties");

System.out.println("in the hibernate function:");
System.out.println("before the session factory");




SessionFactory sessionFactory=new Configuration().addFile("D:/hibernate.cfg.xml").buildSessionFactory();







session=sessionFactory.openSession();
//session=sessions.openSession();


Transaction tx=session.beginTransaction();
String sqlQuery="from ICaptureDbEO as master where master.FORM_ID='LTR19'";//"+formID+"'";


Connection conntn=session.connection();
System.out.println("THIS IS THE CONNECTION OBJECT: "+conntn);
System.out.println("B4 THE QUERY");
Query query=session.createQuery(sqlQuery);
System.out.println("AFTER THE QUERY"+query);

for(Iterator it=query.iterate();it.hasNext()
{
System.out.println("inside the iterator");
row=(ICaptureDbEO)it.next();
System.out.println("recid"+row.getREC_ID());
System.out.println("formid:"+row.getFORM_ID());
System.out.println("form descrition:"+row.getFORM_DESCRIPTION());
System.out.println("dyas to complete:"+row.getDAYS_TO_COMPLETE_WORK());
System.out.println("incoming:"+row.getINCOMING());
}

tx.commit();
}


catch(Exception e)
{
dbLogger.error("EXCEPTION OCCURED DURING DATABASE INTERACTION:"+e);
e.printStackTrace();
}
finally
{
session.close();
}

}




}//CLASS ENDS HERE


when i am running this code as a standalone apllication on dos it is giving java.lang.nullpointer exception when the new Configure() method is invoked

please tell mee why it is happening and how can it be solved?
[ August 02, 2006: Message edited by: Bear Bibeault ]

AMRIT PURSNANI
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 23395

Hi,

Welcome to JavaRanch!

I don't see "new Configure()" anyplace; I do see "new Configuration()" -- is that what you mean?

Please copy the whole stack trace and paste it into a reply to this topic; then we'll be better able to tell you what's going on.


[Jess in Action][AskingGoodQuestions]
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 16622

Try putting you "D:/hibernate.cfg.xml" file in your root of your classpath.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
amrit pursnani
Greenhorn

Joined: Aug 02, 2006
Posts: 9
yes i mean configuration() only
source of classpath means source where jars are kept or source where my class files are kept
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 16622

classpath as in, you have a directory with source code in it for your model. so I have

c:\myproject\app\src\org\jboss\model\

in the classpath being set to c:\myproject\app\src, so that is the directory you would put your config file. Then you don't put a specific path to get to the config file, it is in your classpath.

Mark
amrit pursnani
Greenhorn

Joined: Aug 02, 2006
Posts: 9
Thanks Mark
 
 
subject: java.lang.nullpointer
 
Threads others viewed
Hibernate
delete query in hibernate giving error as null, and not deleting the record
Unable to fetch results using createQuery
Delete Query problem: Failure to Commit HQL Delete Transaction
java.lang.Nullpointer Exception
developer file tools

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture