File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Conversion of int to String in a Vector Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Conversion of int to String in a Vector" Watch "Conversion of int to String in a Vector" New topic
Author

Conversion of int to String in a Vector

Naveen R R
Greenhorn

Joined: May 04, 2001
Posts: 20
Could anyone please tell me as to how to convert an int to a String and add that to a vector?
Please look at the code below:
public class AssignRoleParams {
private String roleId;
private String persTyp;
private int persNbr;
......
......
public void setPersNbr(int newPersNbr) {
persNbr = newPersNbr;
}
public int getPersNbr() {
return persNbr;
}
}

public void assignRole(AssignRoleParams roleAssign) {
db.DBAccess dba = null;
String sql = null;
try {
String roleId = roleAssign.getRoleId();
String persTyp = roleAssign.getPersTyp();
///??? (persNbr is an int)
String persNbr = roleAssign.getPersNbr();//This is
not correct
dba = new db.DBAccess(connection);
java.util.Vector input = new java.util.Vector();
sql = "INSERT INTO PROJOWNER.PERS_ROLE_ASSN
(ROLE_ID, PERS_TYP, PERS_NBR) VALUES (?, ?, ?)";
input.addElement(roleId);
input.addElement(persType);
///???How do I do this?
input.addElement(persNbr);

dba.executeUpdate(sql, input);
} catch (Exception e) {}
}
Thank you,
Naveen
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
What you want to do is wrap an Integer object around your int.
Ex:
Integer intWrapper = new Integer (roleAssign.getPersNbr())
Bosun


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Naveen R R
Greenhorn

Joined: May 04, 2001
Posts: 20
Thanks, Bosun. It works now.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Conversion of int to String in a Vector