[Logo]
Forums Register Login
Hi Friends i have got an error excuting the hibernate program in MyEclipse IDE
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.



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...
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?
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??
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards


This thread has been viewed 808 times.

All times above are in ranch (not your local) time.
The current ranch time is
Jan 18, 2018 06:55:04.