• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
gantayya b bokka
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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.



 
Ankit Garg
Sheriff
Posts: 9610
37
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • 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...
 
Vijitha Kumara
Bartender
Posts: 4002
42
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • 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: 9610
37
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • 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??
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!