-->
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.  [ 2 posts ] 
Author Message
 Post subject: org.hibernate.exception.SQLGrammarException: could not inser
PostPosted: Sun Jun 05, 2011 2:08 pm 
Newbie

Joined: Sun Jun 05, 2011 1:49 pm
Posts: 3
Hi,

Stuck with this error for the past three days.

org.hibernate.exception.SQLGrammarException: could not insert: [com.Course]
at org.hibernate.exception.CacheSQLStateConverter.convert(CacheSQLStateConverter.java:89)
............
at com.Main.saveCourse(Main.java:43)
at com.Main.main(Main.java:19)
Caused by: java.sql.SQLException: [SQLCODE: <-30>:<Table or View not found>]
[Cache Error: <<SYNTAX>errdone+2^%qaqqt>]
[Details: <Prepare>]
[%msg: < SQL ERROR #30: Table 'SQLUSER.COURSE' not found>]
at com.intersys.jdbc.CacheConnection.getServerError(CacheConnection.java:1057)

Code provided below. Using intersystems cache

hibernate.cfg.xml

<hibernate-configuration>
<session-factory name="SessionFactory">
<property name="hibernate.connection.driver_class">com.intersys.jdbc.CacheDriver</property>
<property name="hibernate.connection.password">SYS</property>
<property name="hibernate.connection.url">jdbc:Cache://127.0.0.1:1972/USER</property>
<property name="hibernate.connection.username">_SYSTEM</property>
<property name="hibernate.dialect">org.hibernate.dialect.Cache71Dialect</property>
<mapping resource="com/Course.hbm.xml"/>
</session-factory>
</hibernate-configuration>

Course.hbm.xml

<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Jun 4, 2011 11:09:14 PM by Hibernate Tools 3.4.0.CR1 -->
<hibernate-mapping>
<class name="com.Course" table="SQLUSER.COURSE">(Have tried with COURSE as well)
<id name="courseId" type="long">
<column name="COURSEID" />
<generator class="assigned" />
</id>
<property name="courseName" type="java.lang.String">
<column name="COURSENAME" />
</property>
</class>
</hibernate-mapping>

Main.java

public static void main(String[] args) {
// TODO Auto-generated method stub
Main obj=new Main();
System.out.println("main");
obj.saveCourse("Physics");
obj.saveCourse("Chemistry");
obj.saveCourse("Maths");
}
public void saveCourse(String subject)
{
Session sess=HibernateUtil.getSessionFactory().openSession();
Transaction trans= null;
Long courseId=null;
try
{
trans=sess.beginTransaction();
trans.begin();
Course course=new Course();
course.setCourseName(subject);
courseId= (Long)sess.save(course);
trans.commit();
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
sess.close();
}
}

Would be very helpful if someone could point out the issue in the above code.

Thanks.
Vickram


Top
 Profile  
 
 Post subject: Re: org.hibernate.exception.SQLGrammarException: could not inser
PostPosted: Wed Jun 08, 2011 1:08 pm 
Newbie

Joined: Sun Jun 05, 2011 1:49 pm
Posts: 3
When I ran the prog after I created the table explicitly, it worked fine. Seems like I need to write code for creation of the database table....

Anyways, my problem is solved...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.