• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Strange Error

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I am trying to execute a program to insert values into a table named Contact present in mysql. This same program was working about a two weeks back. I did not touch it for the last two weeks. Now when i run it i am getteing the following message:



The table Contact which is in MYSQL looks like the following:

Column Type
---------------------------
ID int
FIRSTNAME varchar
LASTNAME varchar
EMAIL varchar


My .hbm.xml file looks like the following:




The class Contact looks like the following:


And the class InsertExample.java in which i do the data insertion looks like the following:



What could be the reason for this output?

Kindly help.

Thanks,
Subhash
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Exception in thread "main" java.lang.NullPointerException
at roseindia.tutorial.hibernate.InsertExample.main(InsertExample.java:41)


What happens on line 41 of InsertExample?
 
subhashchandra medhiassam
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That line corresponds to "session.flush();". Anyway, the problem is solved now. Thanks, for your response, Paul.
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So what was your error? Did the session fail to be created in the first place? Or the SessionFactory configuration fail?

Its a good idea to enclose the session.close() code in a null check to avoid this condition.
 
There were millions of the little blood suckers. But thanks to this tiny ad, I wasn't bitten once.
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic