Earlier had worked with hibernate framework with oracl and mysql database. Now I am trying the same with the Postgres database. But I am not able to save the data. Please find my files below:
I am able to get a connection to the postgres database as well. But when I execute the main class (SaveDemo.java), the values are not being inserted into the db. Also I am not getting any errors or exception for the same.
...though of course, if calling commit() in the finally block is " throwing some error " moving it to the catch block is unlikely to fix this. What is the error?
Once again stuck up with a small issue.But I am not able to figure it out. In the previously mentioned code snippet, when the control invokes the below line of code, the control is directly moving to the session.close() method of the finally block :
When it's moving to the finally-bock without printing some of the System.outs you have in there, there should be a stacktrace which might help us a little bit...
As you didn't post the code of your program, we cannot know whats in line 53. I think it is "session.close()" which is inside a finally block. Something went wrong opening the connection, a runtime exception occured which you re-throw. After that the finally-block is being processed where the NPE occurs because the session is null. But as you didn't post the stacktrace of the exception we cannot know, what happened exactly. There MUST be a stacktrace. You could print it right before re-throwing the RuntimeException.