当前位置:首页 » 数据仓库 » 如何判断数据库为空
扩展阅读
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 字段=''是判断为空