facebook

net.sf.hibernate.exception.SQLGrammarException

💡
Our Forums Have Moved

For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub

  1. MyEclipse IDE
  2.  > 
  3. Off Topic
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #251847 Reply

    easyuploader
    Member

    hai, I am developing my first web application using hibernate and postgresql as the database. I had created a database in postgresql and had two colums in it. when i am trying to insert values into that databse through my following program,
    import net.sf.hibernate.*;

    public class HibernateTest {

    public static void main(String[] args) {
    Employee message = new Employee();
    message.getClass();
    message.setEmployeeid(“14”);
    message.setEmpname(“happy”);
    Transaction tx=null;
    try {
    Session session = SessionManager.currentSession();
    tx = session.beginTransaction();
    session.save(message);
    tx.commit();
    System.out.println(“Save successful.”);
    } catch (HibernateException e) {
    try {
    tx.rollback();
    } catch (HibernateException e1) {
    System.out.println(e1);
    }
    System.out.println(e.toString());
    e.printStackTrace();
    if(e.getCause()!= null)
    System.out.println(e.getCause().getMessage());
    }
    finally {
    try {
    SessionManager.closeSession();
    } catch (HibernateException e2) {
    }
    }
    }
    }

    When i am trying to run this application i am getting the following error
    log4j:WARN No appenders could be found for logger (net.sf.hibernate.cfg.Environment).
    log4j:WARN Please initialize the log4j system properly.
    net.sf.hibernate.exception.SQLGrammarException: Could not save object
    at net.sf.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:59)
    at net.sf.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:30)
    at net.sf.hibernate.impl.SessionImpl.convert(SessionImpl.java:4110)
    at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:792)
    at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:747)
    at com.nanna.hibernate.HibernateTest.main(HibernateTest.java:32)
    Caused by: org.postgresql.util.PSQLException: ERROR: column “employeeid” does not exist
    at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1512)
    at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1297)
    at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:188)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:430)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:346)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:250)
    at net.sf.hibernate.id.IncrementGenerator.getNext(IncrementGenerator.java:68)
    at net.sf.hibernate.id.IncrementGenerator.generate(IncrementGenerator.java:42)
    at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:774)
    … 2 more
    net.sf.hibernate.exception.SQLGrammarException: Could not save object
    ERROR: column “employeeid” does not exist

    But there is the colum employeeid in the database. I could not figure out where i went wrong. please help me.

    #251879

    Riyad Kalla
    Member

    Paste the CREAET TABLE statement for your table and the hbm.xml file for us to see.

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: net.sf.hibernate.exception.SQLGrammarException

You must be logged in to post in the forum log in