Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Conversion of int to String in a Vector

 
Naveen R R
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What you want to do is wrap an Integer object around your int.
Ex:
Integer intWrapper = new Integer (roleAssign.getPersNbr())
Bosun
 
Naveen R R
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Bosun. It works now.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic