• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Hi Friends i have got an error excuting the hibernate program in MyEclipse IDE

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello i have doubt in executing the hibernate program on MYECLIPSE IDE please clarify this one
i have used Oracle xe for database.
i have created the table in the database as follows.
sql>create table emp(empno number(3),empname varchar2(10), empsalary number(5));
and then am done what ever stuff is there to execute the program
and then i create class in the package org.stud;
my class name is MyCls and myprogram is as follows

package org.stud;
import org.hibernate.*;
public class MyCls {
public static void main(String[] args)throws Exception {
Session hsession=org.stud.OraSF.getSession();
Transaction tx=hsession.beginTransaction();
org.stud.Emp emp=new org.stud.Emp();
emp.setEmpno(new Long(1));
emp.setEmpname("raj");
emp.setEmpsalary(new Double(133));
hsession.save(emp);
tx.commit();
org.stud.OraSF.closeSession();
}
}


i got the errors in the program emp.setEmpno(),emp.setEmpname()and emp.setSalary()
tell me how the errors came and then am executing the program eclipse show the errors as

Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The method setempno(Long) is undefined for the type Emp
The method setempname(String) is undefined for the type Emp
The method setempsal(Double) is undefined for the type Emp

at org.stud.MyCls.main(MyCls.java:9)


please solve this one and give me answer for me.



 
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please take time to Carefully Choose One Forum when you start a topic. The SCJP forum is not appropriate for your question. There isn't enough information provided by you to guess what the problem is with so I'll move it to the General Java Forum...
 
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Looks like you have compiler errors in the program, before trying to execute you should solve those first. Does your "Emp" class contain "setEmpno(), ... " methods?
 
Ankit Garg
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The only things that comes to my notice is that the code says

emp.setEmpno(new Long(1));
emp.setEmpname("raj");
emp.setEmpsalary(new Double(133));

and the error says

The method setempno(Long) is undefined for the type Emp
The method setempname(String) is undefined for the type Emp
The method setempsal(Double) is undefined for the type Emp

So it seems somehow one of your class has the wrong version on runtime i.e. either org.stud.MyCls available to the JVM is not the same as the code you've shown or the class org.stud.Emp is an old version on runtime. Are there multiple classes with the same name in different directories on the class path??
 
reply
    Bookmark Topic Watch Topic
  • New Topic