/** * 执行INSERT, UPDATE 以及DELETE操作 * * @param getSqlBuilder Sql语句构建器 * @return */ public boolean execute(SqlBuilder getSqlBuilder) { boolean isSuccess = false; String sqlString; try { sqlString = getSqlBuilder.getSqlStatement(); execute(sqlString, null); isSuccess = true; } catch (IllegalArgumentException e) { // TODO Auto-generated catch block isSuccess = false; e.printStackTrace(); } catch (CHDBException e) { // TODO Auto-generated catch block isSuccess = false; e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block isSuccess = false; e.printStackTrace(); } catch (CHDBNotOpenException e) { // TODO Auto-generated catch block e.printStackTrace(); isSuccess = false; } return isSuccess; }
/** * 创建表 * * @param clazz * @return 为true创建成功,为false创建失败 */ public boolean creatTable(Class<?> clazz) { boolean isSuccess = false; if (testSQLiteDatabase()) { try { String sqlString = DBUtils.creatTableSql(clazz); execute(sqlString, null); isSuccess = true; } catch (CHDBException e) { // TODO Auto-generated catch block isSuccess = false; e.printStackTrace(); CHLogger.e(SQLiteDB.this, e.getMessage()); } catch (CHDBNotOpenException e) { // TODO Auto-generated catch block isSuccess = false; e.printStackTrace(); CHLogger.e(SQLiteDB.this, e.getMessage()); } } else { CHLogger.e(SQLiteDB.this, "数据库未打开!"); return false; } return isSuccess; }