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]);
}
添加您的代碼。 –
我在代碼所在的位置附加了鏈接。 –