首先,我有两个字符串:注册 ID 和用户名。这两个字符串是连接在一起的。
为什么连接两个字符串,因为有时用户名相同但注册ID不同所以
我有这个代码:
public ArrayList getStudentUser(int check,int userid,int mgmtid)
{
ArrayList companyList = new ArrayList();
Session session = null;
PreparedStatement pst = null;
ResultSet rst = null;
try {
session = HibernateUtil.getSession();
if(check==1){
String query = "select a.firstname,a.lastName,b.RegistarionId from t_vs_users a inner join t_vs_userdetails b on b.UserId=a.User_ID where a. RoleId=5 and SourceId=? and a.User_ID not in (?)";
pst = session.connection().prepareStatement(query);
pst.setInt(1, mgmtid);
pst.setInt(2, userid);
rst = pst.executeQuery();
while(rst.next()) {
companyList.add(rst.getString("firstname")+""+(rst.getString("lastName"))+","+rst.getString("RegistarionId"));
}
} else {
String query = "select a.firstname,a.lastName,b.RegistarionId from t_vs_users a inner join t_vs_userdetails b on b.UserId=a.User_ID where a. RoleId=5 and SourceId=? and a.User_ID not in (?)";
pst = session.connection().prepareStatement(query);
pst.setInt(1, mgmtid);
pst.setInt(2, userid);
rst = pst.executeQuery();
while(rst.next()) {
companyList.add(rst.getString("RegistarionId")+","+(rst.getString("firstname"))+""+rst.getString("lastName"));
}
}
}catch(Exception e)
{
e.printStackTrace();
}
return companyList;
}
public boolean checkIfNumber(String in) {
try {
Integer.parseInt(in);
} catch (NumberFormatException ex) {
return false;
}
return true;
}
我进入连接字符串 getStudentUser 但我只想要注册 ID 如何拆分