當前位置:首頁 » 數據倉庫 » 如何判斷資料庫為空
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

如何判斷資料庫為空

發布時間: 2022-12-09 08:40:53

Ⅰ 高手救急啊!!!如何判斷資料庫(表)中的內容為空(寫出一個語句)

/*
* 判斷表_command中是否存有命令
*/
@Override
public boolean ifExistsCommand() {
String query_sql = "select Count(*) from _command ; ";
Connection conn = DB.createConn();
PreparedStatement ps = DB.prepare(conn, query_sql);
ResultSet rs = null;
try {
rs = ps.executeQuery(query_sql);
} catch (SQLException e) {
e.printStackTrace();
}

int rows = 0;
if(null!=rs)
{
try {
while(rs.next()){
rows = rs.getInt(1);
}
} catch (SQLException e) {
e.printStackTrace();
}
}
DB.close(ps);
DB.close(conn);
if (rows > 0) {
return true;//當查詢的結果不為空時返回true
} else {
return false;
}
}

Ⅱ 怎麼判斷資料庫的某個欄位值為空

where 欄位 is null 是判斷為null的
where 欄位=''是判斷為空