• Post Reply Bookmark Topic Watch Topic
  • New Topic

javabean  RSS feed

 
prem kumar vadivelu
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
import java.io.*;
import java.sql.*;
import java.lang.String.*;
public class Empbean implements Serializable
{
private String opt;
private int id;
private String ename;
private String errmsg;
Empbean()
{}
public void setId(int id)
{
this.id=id;
}
public int getId()
{
return id;
}
public void setOpt(String opt)
{
this.opt=opt;
}
public int getOpt()
{
return opt;
}
public void setEname(String ename)
{
this.ename=ename;
}
public int getEname()
{
return ename;
}
public void setErrmsg(String errmsg)
{
this.errmsg=errmsg;
}
public int getErrmsg()
{
return errmsg;
}
boolean isValidate()
{
boolean b=true;
if(id==null)
{
errmsg="invalid id";
b=false;
}
else if(ename==null)
{
errmsg="invalid name";
b=false;
}
return b;
}
boolean saveEmpInfo()
{
boolean b=true;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:database");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from data2");
id=getId();
ename=getEname();
opt=getOpt();
errmsg=getErrmsg();
while(rs.next())
{
int n1=rs.getInt(1);
String s1=rs.getString(2);


if(opt.equals("add"))
{
int sr=st.executeUpdate("insert into data values("+ id +",'"+ ename +"')");
b=false;
}

else if(opt.equals("mod"))
{
st.executeUpdate("update data set empname=('"+ ename +"') where empid=("+ id +")");
b=false;
}
else if(opt.equals("del"))
{
st.executeUpdate("delete from data where empid=("+ id +")");
b=false;
}
}
}
catch(Exception e)
{

}
return b;
}
}

its showing errormsg
Empbean.java:26: incompatible types
found : java.lang.String
required: int
return opt;
^
Empbean.java:34: incompatible types
found : java.lang.String
required: int
return ename;
^
Empbean.java:42: incompatible types
found : java.lang.String
required: int
return errmsg;
^
Empbean.java:47: incomparable types: int and <nulltype>
if(id==null)
^
Empbean.java:69: incompatible types
found : int
required: java.lang.String
ename=getEname();
^
Empbean.java:70: incompatible types
found : int
required: java.lang.String
opt=getOpt();
^
Empbean.java:71: incompatible types
found : int
required: java.lang.String
errmsg=getErrmsg();
^
can any one help me to solve this
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch!

Please UseCodeTags when posting code or configuration. Unformatted code and configuration is unnecessarily difficult to read. You can edit your post by using the button.

The error message is indicating precisely what's wrong: the return types don't match the types of the values you're returning.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66304
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, please be sure to take the time to compose descriptive subjects for your posts. You will attract people who will can give you better and faster answers when your posts have good, descriptive subjects. For more information, please click this link ⇒ UseAMeaningfulSubjectLine.

Using a title such as "javabean" isn't going to attract the attention of those who can best help you.

You can change your subject line by clicking the button on your post.
 
sihani rani
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey

you declare "opt,errmsg,ename" are all in string format...
when you get value ,you use "int" format..so only error occured..
so change 'int' to 'string' type..

 
prem kumar vadivelu
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
quit
 
Rob Spoor
Sheriff
Posts: 21133
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Command-line interface to JavaRanch.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!