1
数据库中获取值的问题我正在使用sql server数据库来存储和检索数据库中的值。现在我读取每一行并在每列数据之间添加“〜”。在调用函数的时候,我用相同的(〜)分割它。现在我的问题是,如果一些字段在数据库中是空白的,所以我没有返回空格,所以我如何管理空白数据以在写入位置显示。我对此很新颖。如果知道一个人可以理解这个场景,可以随意问。谢谢你。从我的应用程序中的android
//Function Definition
public String[] selectPhoneDirectory(String siteId){
String[] detailofemployee = new String[25];
openConnection();
String query = "Select * from Telephone_master with(nolock) where Site_ID = '"+siteId+"' order by User_Name";
int i =0;
try{
rs = st.executeQuery(query);
while(rs.next()){
detailofemployee[i] = rs.getString(3)+"~"+rs.getString(4)+"~"+rs.getString(5)+"~"+rs.getString(6)+"~"+rs.getString(7);
System.out.println("The Detail Is :"+detailofemployee[i]);
i++;
}
}
catch (Exception e) {
System.out.println("Error!!!"+e);
}
closeConnection();
return detailofemployee;
}
//Calling Function
for(int i = 0; i < siteName.length; i++){
if(siteName[i].equalsIgnoreCase(strselectedName)){
detailEmployee = gd.selectPhoneDirectory(siteId[i]);
}
for(int j = 0 ;j < detailEmployee.length ; j++){
StringTokenizer st =new StringTokenizer(detailEmployee[j]);
empName[j] = new String();
empName[j] = st.nextToken("~").toString();
System.out.println("The Name Is :"+empName[j]);
empHome[j] = new String();
empHome[j] = st.nextToken("~").toString();
System.out.println("The Home No Is :"+empHome[j]);
empMob[j] = new String();
empMob[j] = st.nextToken("~").toString();
System.out.println("The Mobile No Is :"+empMob[j]);
}
添加您的代码。 –
我在代码所在的位置附加了链接。 –