本文整理汇总了Java中org.xutils.ex.DbException类的典型用法代码示例。如果您正苦于以下问题:Java DbException类的具体用法?Java DbException怎么用?Java DbException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DbException类属于org.xutils.ex包,在下文中一共展示了DbException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: DownloadManager
import org.xutils.ex.DbException; //导入依赖的package包/类
private DownloadManager() {
DbManager.DaoConfig daoConfig = new DbManager.DaoConfig()
.setDbName("download")
.setDbVersion(1);
db = x.getDb(daoConfig);
try {
List<DownloadInfo> infoList = db.selector(DownloadInfo.class).findAll();
if (infoList != null) {
for (DownloadInfo info : infoList) {
if (info.getState().value() < DownloadState.FINISHED.value()) {
info.setState(DownloadState.STOPPED);
}
downloadInfoList.add(info);
}
}
} catch (DbException ex) {
LogUtil.e(ex.getMessage(), ex);
}
}
示例2: onLoading
import org.xutils.ex.DbException; //导入依赖的package包/类
@Override
public void onLoading(long total, long current, boolean isDownloading) {
if (isDownloading) {
try {
downloadInfo.setState(DownloadState.STARTED);
downloadInfo.setFileLength(total);
downloadInfo.setProgress((int) (current * 100 / total));
downloadManager.updateDownloadInfo(downloadInfo);
} catch (DbException ex) {
LogUtil.e(ex.getMessage(), ex);
}
DownloadViewHolder viewHolder = this.getViewHolder();
if (viewHolder != null) {
viewHolder.onLoading(total, current);
}
}
}
示例3: findFirst
import org.xutils.ex.DbException; //导入依赖的package包/类
public T findFirst() throws DbException {
if (!table.tableIsExist()) return null;
this.limit(1);
Cursor cursor = table.getDb().execQuery(this.toString());
if (cursor != null) {
try {
if (cursor.moveToNext()) {
return CursorUtils.getEntity(table, cursor);
}
} catch (Throwable e) {
throw new DbException(e);
} finally {
IOUtil.closeQuietly(cursor);
}
}
return null;
}
示例4: findAll
import org.xutils.ex.DbException; //导入依赖的package包/类
public List<T> findAll() throws DbException {
if (!table.tableIsExist()) return null;
List<T> result = null;
Cursor cursor = table.getDb().execQuery(this.toString());
if (cursor != null) {
try {
result = new ArrayList<T>();
while (cursor.moveToNext()) {
T entity = CursorUtils.getEntity(table, cursor);
result.add(entity);
}
} catch (Throwable e) {
throw new DbException(e);
} finally {
IOUtil.closeQuietly(cursor);
}
}
return result;
}
示例5: delete
import org.xutils.ex.DbException; //导入依赖的package包/类
@Override
public int delete(Class<?> entityType, WhereBuilder whereBuilder) throws DbException {
TableEntity<?> table = this.getTable(entityType);
if (!table.tableIsExist()) return 0;
int result = 0;
try {
beginTransaction();
result = executeUpdateDelete(SqlInfoBuilder.buildDeleteSqlInfo(table, whereBuilder));
setTransactionSuccessful();
} finally {
endTransaction();
}
return result;
}
示例6: update
import org.xutils.ex.DbException; //导入依赖的package包/类
@Override
public int update(Class<?> entityType, WhereBuilder whereBuilder, KeyValue... nameValuePairs) throws DbException {
TableEntity<?> table = this.getTable(entityType);
if (!table.tableIsExist()) return 0;
int result = 0;
try {
beginTransaction();
result = executeUpdateDelete(SqlInfoBuilder.buildUpdateSqlInfo(table, whereBuilder, nameValuePairs));
setTransactionSuccessful();
} finally {
endTransaction();
}
return result;
}
示例7: findById
import org.xutils.ex.DbException; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public <T> T findById(Class<T> entityType, Object idValue) throws DbException {
TableEntity<T> table = this.getTable(entityType);
if (!table.tableIsExist()) return null;
Selector selector = Selector.from(table).where(table.getId().getName(), "=", idValue);
String sql = selector.limit(1).toString();
Cursor cursor = execQuery(sql);
if (cursor != null) {
try {
if (cursor.moveToNext()) {
return CursorUtils.getEntity(table, cursor);
}
} catch (Throwable e) {
throw new DbException(e);
} finally {
IOUtil.closeQuietly(cursor);
}
}
return null;
}
示例8: findDbModelFirst
import org.xutils.ex.DbException; //导入依赖的package包/类
@Override
public DbModel findDbModelFirst(SqlInfo sqlInfo) throws DbException {
Cursor cursor = execQuery(sqlInfo);
if (cursor != null) {
try {
if (cursor.moveToNext()) {
return CursorUtils.getDbModel(cursor);
}
} catch (Throwable e) {
throw new DbException(e);
} finally {
IOUtil.closeQuietly(cursor);
}
}
return null;
}
示例9: findDbModelAll
import org.xutils.ex.DbException; //导入依赖的package包/类
@Override
public List<DbModel> findDbModelAll(SqlInfo sqlInfo) throws DbException {
List<DbModel> dbModelList = new ArrayList<DbModel>();
Cursor cursor = execQuery(sqlInfo);
if (cursor != null) {
try {
while (cursor.moveToNext()) {
dbModelList.add(CursorUtils.getDbModel(cursor));
}
} catch (Throwable e) {
throw new DbException(e);
} finally {
IOUtil.closeQuietly(cursor);
}
}
return dbModelList;
}
示例10: getLastAutoIncrementId
import org.xutils.ex.DbException; //导入依赖的package包/类
private long getLastAutoIncrementId(String tableName) throws DbException {
long id = -1;
Cursor cursor = execQuery("SELECT seq FROM sqlite_sequence WHERE name='" + tableName + "' LIMIT 1");
if (cursor != null) {
try {
if (cursor.moveToNext()) {
id = cursor.getLong(0);
}
} catch (Throwable e) {
throw new DbException(e);
} finally {
IOUtil.closeQuietly(cursor);
}
}
return id;
}
示例11: executeUpdateDelete
import org.xutils.ex.DbException; //导入依赖的package包/类
@Override
public int executeUpdateDelete(SqlInfo sqlInfo) throws DbException {
SQLiteStatement statement = null;
try {
statement = sqlInfo.buildStatement(database);
return statement.executeUpdateDelete();
} catch (Throwable e) {
throw new DbException(e);
} finally {
if (statement != null) {
try {
statement.releaseReference();
} catch (Throwable ex) {
LogUtil.e(ex.getMessage(), ex);
}
}
}
}
示例12: execNonQuery
import org.xutils.ex.DbException; //导入依赖的package包/类
@Override
public void execNonQuery(SqlInfo sqlInfo) throws DbException {
SQLiteStatement statement = null;
try {
statement = sqlInfo.buildStatement(database);
statement.execute();
} catch (Throwable e) {
throw new DbException(e);
} finally {
if (statement != null) {
try {
statement.releaseReference();
} catch (Throwable ex) {
LogUtil.e(ex.getMessage(), ex);
}
}
}
}
示例13: tableIsExist
import org.xutils.ex.DbException; //导入依赖的package包/类
public boolean tableIsExist() throws DbException {
if (this.isCheckedDatabase()) {
return true;
}
Cursor cursor = db.execQuery("SELECT COUNT(*) AS c FROM sqlite_master WHERE type='table' AND name='" + name + "'");
if (cursor != null) {
try {
if (cursor.moveToNext()) {
int count = cursor.getInt(0);
if (count > 0) {
this.setCheckedDatabase(true);
return true;
}
}
} catch (Throwable e) {
throw new DbException(e);
} finally {
IOUtil.closeQuietly(cursor);
}
}
return false;
}
示例14: getTable
import org.xutils.ex.DbException; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public <T> TableEntity<T> getTable(Class<T> entityType) throws DbException {
synchronized (tableMap) {
TableEntity<T> table = (TableEntity<T>) tableMap.get(entityType);
if (table == null) {
try {
table = new TableEntity<T>(this, entityType);
} catch (Throwable ex) {
throw new DbException(ex);
}
tableMap.put(entityType, table);
}
return table;
}
}
示例15: createTableIfNotExist
import org.xutils.ex.DbException; //导入依赖的package包/类
protected void createTableIfNotExist(TableEntity<?> table) throws DbException {
if (!table.tableIsExist()) {
synchronized (table.getClass()) {
if (!table.tableIsExist()) {
SqlInfo sqlInfo = SqlInfoBuilder.buildCreateTableSqlInfo(table);
execNonQuery(sqlInfo);
String execAfterTableCreated = table.getOnCreated();
if (!TextUtils.isEmpty(execAfterTableCreated)) {
execNonQuery(execAfterTableCreated);
}
table.setCheckedDatabase(true);
TableCreateListener listener = this.getDaoConfig().getTableCreateListener();
if (listener != null) {
listener.onTableCreated(this, table);
}
}
}
}
}