JAVA代码判断数据库表是否存在
2013-09-10 14:44
267 查看
public boolean tabbleIsExist(String tableName){
boolean result = false;
if(tableName == null){
return false;
}
SQLiteDatabase db = null;
Cursor cursor = null;
try {
db = mDbHelper.getReadableDatabase();
String sql = "select count(*) as c from Sqlite_master where type ='table' and name ='"+tableName.trim()+"' ";
cursor = db.rawQuery(sql, null);
if(cursor.moveToNext()){
int count = cursor.getInt(0);
if(count>0){
result = true;
}
}
} catch (Exception e) {
// TODO: handle exception
}
return result;
}
boolean result = false;
if(tableName == null){
return false;
}
SQLiteDatabase db = null;
Cursor cursor = null;
try {
db = mDbHelper.getReadableDatabase();
String sql = "select count(*) as c from Sqlite_master where type ='table' and name ='"+tableName.trim()+"' ";
cursor = db.rawQuery(sql, null);
if(cursor.moveToNext()){
int count = cursor.getInt(0);
if(count>0){
result = true;
}
}
} catch (Exception e) {
// TODO: handle exception
}
return result;
}
相关文章推荐
- Java代码判断数据库中某张表是否存在
- Java代码 给出一个二叉树和一个数,判断该二叉树是否存在一个从根节点到叶节点的和与给出的数相同
- 代码实例Java IO判断目录和文件是否存在
- android代码中判断数据库的某张表是否存在
- JAVA判断数据表是否在数据库中存在的方法
- java根据表名判断数据库表是否存在
- Java判断数据库结果集ResultSet 中是否存在指定列名
- java 判断数据库表是否存在,不存在则创建。
- sql 判断数据库,表,存储过程等是否存在的代码
- 用Java语句判断数据库表是否存在
- sql 判断数据库,表,存储过程等是否存在的代码
- 一段很好用的判断数据库中某张表是否存在的代码[转]
- 用Java语句判断数据库表是否存在
- Mysql+java后台判断数据库表是否存在
- sql 判断数据库,表,存储过程等是否存在的代码(教程)
- 用java判断数据库某个表是否存在
- 摘录:java和sql如何判断数据库是否存在
- 用Java语句判断数据库表是否存在
- 用Java语句判断数据库表是否存在
- sql 判断数据库,表,存储过程等是否存在的代码