• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java DbException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.xutils.ex.DbException的典型用法代码示例。如果您正苦于以下问题:Java DbException类的具体用法?Java DbException怎么用?Java DbException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DbException类属于org.xutils.ex包,在下文中一共展示了DbException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:DownloadManager.java


示例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);
        }
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:DownloadCallback.java


示例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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:Selector.java


示例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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:Selector.java


示例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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:DbManagerImpl.java


示例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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:DbManagerImpl.java


示例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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:DbManagerImpl.java


示例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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:DbManagerImpl.java


示例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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:DbManagerImpl.java


示例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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:DbManagerImpl.java


示例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);
            }
        }
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:DbManagerImpl.java


示例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);
            }
        }
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:DbManagerImpl.java


示例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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:TableEntity.java


示例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;
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:DbBase.java


示例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);
                }
            }
        }
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:DbBase.java


示例16: buildDeleteSqlInfo

import org.xutils.ex.DbException; //导入依赖的package包/类
public static SqlInfo buildDeleteSqlInfo(TableEntity<?> table, Object entity) throws DbException {
    SqlInfo result = new SqlInfo();

    ColumnEntity id = table.getId();
    Object idValue = id.getColumnValue(entity);

    if (idValue == null) {
        throw new DbException("this entity[" + table.getEntityType() + "]'s id value is null");
    }
    StringBuilder builder = new StringBuilder("DELETE FROM ");
    builder.append("\"").append(table.getName()).append("\"");
    builder.append(" WHERE ").append(WhereBuilder.b(id.getName(), "=", idValue));

    result.setSql(builder.toString());

    return result;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:SqlInfoBuilder.java


示例17: buildDeleteSqlInfoById

import org.xutils.ex.DbException; //导入依赖的package包/类
public static SqlInfo buildDeleteSqlInfoById(TableEntity<?> table, Object idValue) throws DbException {
    SqlInfo result = new SqlInfo();

    ColumnEntity id = table.getId();

    if (idValue == null) {
        throw new DbException("this entity[" + table.getEntityType() + "]'s id value is null");
    }
    StringBuilder builder = new StringBuilder("DELETE FROM ");
    builder.append("\"").append(table.getName()).append("\"");
    builder.append(" WHERE ").append(WhereBuilder.b(id.getName(), "=", idValue));

    result.setSql(builder.toString());

    return result;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:SqlInfoBuilder.java


示例18: buildUpdateSqlInfo

import org.xutils.ex.DbException; //导入依赖的package包/类
public static SqlInfo buildUpdateSqlInfo(TableEntity<?> table, WhereBuilder whereBuilder, KeyValue... nameValuePairs) throws DbException {

        if (nameValuePairs == null || nameValuePairs.length == 0) return null;

        SqlInfo result = new SqlInfo();
        StringBuilder builder = new StringBuilder("UPDATE ");
        builder.append("\"").append(table.getName()).append("\"");
        builder.append(" SET ");
        for (KeyValue kv : nameValuePairs) {
            builder.append("\"").append(kv.key).append("\"").append("=?,");
            result.addBindArg(kv);
        }
        builder.deleteCharAt(builder.length() - 1);
        if (whereBuilder != null && whereBuilder.getWhereItemSize() > 0) {
            builder.append(" WHERE ").append(whereBuilder.toString());
        }

        result.setSql(builder.toString());
        return result;
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:SqlInfoBuilder.java


示例19: findFirst

import org.xutils.ex.DbException; //导入依赖的package包/类
public DbModel findFirst() throws DbException {
    TableEntity<?> table = selector.getTable();
    if (!table.tableIsExist()) return null;

    this.limit(1);
    Cursor cursor = table.getDb().execQuery(this.toString());
    if (cursor != null) {
        try {
            if (cursor.moveToNext()) {
                return CursorUtils.getDbModel(cursor);
            }
        } catch (Throwable e) {
            throw new DbException(e);
        } finally {
            IOUtil.closeQuietly(cursor);
        }
    }
    return null;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:DbModelSelector.java


示例20: findAll

import org.xutils.ex.DbException; //导入依赖的package包/类
public List<DbModel> findAll() throws DbException {
    TableEntity<?> table = selector.getTable();
    if (!table.tableIsExist()) return null;

    List<DbModel> result = null;

    Cursor cursor = table.getDb().execQuery(this.toString());
    if (cursor != null) {
        try {
            result = new ArrayList<DbModel>();
            while (cursor.moveToNext()) {
                DbModel entity = CursorUtils.getDbModel(cursor);
                result.add(entity);
            }
        } catch (Throwable e) {
            throw new DbException(e);
        } finally {
            IOUtil.closeQuietly(cursor);
        }
    }
    return result;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:DbModelSelector.java



注:本文中的org.xutils.ex.DbException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FileUtils类代码示例发布时间:2022-05-22
下一篇:
Java ExtractorOutput类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap