当前位置: 首页>>代码示例>>Java>>正文


Java PreparedQuery类代码示例

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


PreparedQuery类属于com.j256.ormlite.stmt包,在下文中一共展示了PreparedQuery类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: queryLatestEventBefore

import com.j256.ormlite.stmt.PreparedQuery; //导入依赖的package包/类
/**
 * This is used to query a single Event ({@link VaultEntry} before a given point in time.
 * This is useful to determine why certain events might have happened (correlation of events).
 *
 * @param timestamp The point in time to get the preceding event from.
 * @param type The Type of {@link VaultEntry} to query for.
 * @return The event of the {@link VaultEntryType} preceding the specified point in time.
 */
public VaultEntry queryLatestEventBefore(final Date timestamp, final VaultEntryType type) {
    VaultEntry returnValue = null;
    try {

        PreparedQuery<VaultEntry> query
                = vaultDao.queryBuilder().orderBy("timestamp", false)
                .limit(1L)
                .where()
                .eq(VaultEntry.TYPE_FIELD_NAME, type)
                .and()
                .le(VaultEntry.TIMESTAMP_FIELD_NAME, timestamp)
                .prepare();
        List<VaultEntry> tmpList = vaultDao.query(query);
        if (tmpList.size() > 0) {
            returnValue = tmpList.get(0);
        }
    } catch (SQLException exception) {
        LOG.log(Level.SEVERE, "Error while db query", exception);
    }
    return returnValue;
}
 
开发者ID:lucasbuschlinger,项目名称:BachelorPraktikum,代码行数:30,代码来源:VaultDao.java

示例2: queryGlucoseBetween

import com.j256.ormlite.stmt.PreparedQuery; //导入依赖的package包/类
public List<VaultEntry> queryGlucoseBetween(Date from, Date to) {
    List<VaultEntry> returnValues = null;
    try {
        PreparedQuery<VaultEntry> query
                = vaultDao.queryBuilder().orderBy("timestamp", true)
                .where()
                .eq(VaultEntry.TYPE_FIELD_NAME, VaultEntryType.GLUCOSE_BG)
                .or()
                .eq(VaultEntry.TYPE_FIELD_NAME, VaultEntryType.GLUCOSE_CGM)
                .or()
                .eq(VaultEntry.TYPE_FIELD_NAME, VaultEntryType.GLUCOSE_CGM_ALERT)
                .and()
                .between(VaultEntry.TIMESTAMP_FIELD_NAME, from, to)
                .prepare();
        returnValues = vaultDao.query(query);
    } catch (SQLException ex) {
        LOG.log(Level.SEVERE, "Error while db query", ex);
    }
    return returnValues;
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:21,代码来源:VaultDao.java

示例3: queryExerciseBetween

import com.j256.ormlite.stmt.PreparedQuery; //导入依赖的package包/类
public List<VaultEntry> queryExerciseBetween(Date from, Date to) {
    List<VaultEntry> returnValues = null;
    try {
        PreparedQuery<VaultEntry> query
                = vaultDao.queryBuilder().orderBy("timestamp", true)
                .where()
                .eq(VaultEntry.TYPE_FIELD_NAME, VaultEntryType.EXERCISE_BICYCLE)
                .or()
                .eq(VaultEntry.TYPE_FIELD_NAME, VaultEntryType.EXERCISE_RUN)
                .or()
                .eq(VaultEntry.TYPE_FIELD_NAME, VaultEntryType.EXERCISE_WALK)
                .or()
                .eq(VaultEntry.TYPE_FIELD_NAME, VaultEntryType.EXERCISE_MANUAL)
                .and()
                .between(VaultEntry.TIMESTAMP_FIELD_NAME, from, to)
                .prepare();
        returnValues = vaultDao.query(query);
    } catch (SQLException ex) {
        LOG.log(Level.SEVERE, "Error while db query", ex);
    }
    return returnValues;
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:23,代码来源:VaultDao.java

示例4: queryLatestEventBefore

import com.j256.ormlite.stmt.PreparedQuery; //导入依赖的package包/类
public VaultEntry queryLatestEventBefore(Date timestamp, VaultEntryType type) {
    VaultEntry returnValue = null;
    try {

        PreparedQuery<VaultEntry> query
                = vaultDao.queryBuilder().orderBy("timestamp", false)
                .limit(1L)
                .where()
                .eq(VaultEntry.TYPE_FIELD_NAME, type)
                .and()
                .le(VaultEntry.TIMESTAMP_FIELD_NAME, timestamp)
                .prepare();
        List<VaultEntry> tmpList = vaultDao.query(query);
        if (tmpList.size() > 0) {
            returnValue = tmpList.get(0);
        }
    } catch (SQLException ex) {
        LOG.log(Level.SEVERE, "Error while db query", ex);
    }
    return returnValue;
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:22,代码来源:VaultDao.java

示例5: queryVaultEntryById

import com.j256.ormlite.stmt.PreparedQuery; //导入依赖的package包/类
/**
 *
 * @param id
 * @return vault entry with respective id or null
 */
public VaultEntry queryVaultEntryById(long id) {
    List<VaultEntry> returnValues = new ArrayList<>();
    try {
        PreparedQuery<VaultEntry> query
                = vaultDao.queryBuilder().orderBy("timestamp", true)
                .limit(1l)
                .where()
                .eq(VaultEntry.ID_FIELD_NAME, id)
                .prepare();
        returnValues = vaultDao.query(query);
    } catch (SQLException ex) {
        LOG.log(Level.SEVERE, "Error while db query", ex);
        return null;
    }
    return returnValues.get(0);
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:22,代码来源:VaultDao.java

示例6: queryVaultEntrysBetween

import com.j256.ormlite.stmt.PreparedQuery; //导入依赖的package包/类
public List<VaultEntry> queryVaultEntrysBetween(Date from, Date to) {
    List<VaultEntry> returnValues = new ArrayList<>();
    try {
        Date fromTimestamp = TimestampUtils.createCleanTimestamp(from);
        Date toTimestamp = TimestampUtils.createCleanTimestamp(to);

        PreparedQuery<VaultEntry> query
                = vaultDao.queryBuilder().orderBy("timestamp", true)
                .where()
                .between(VaultEntry.TIMESTAMP_FIELD_NAME, fromTimestamp, toTimestamp)
                .prepare();
        returnValues = vaultDao.query(query);
    } catch (SQLException ex) {
        LOG.log(Level.SEVERE, "Error while db query", ex);
    }
    return returnValues;
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:18,代码来源:VaultDao.java

示例7: queryBasalBetween

import com.j256.ormlite.stmt.PreparedQuery; //导入依赖的package包/类
public List<VaultEntry> queryBasalBetween(Date from, Date to) {
    List<VaultEntry> returnValues = null;
    try {
        PreparedQuery<VaultEntry> query
                = vaultDao.queryBuilder().orderBy("timestamp", true)
                .where()
                .eq(VaultEntry.TYPE_FIELD_NAME, VaultEntryType.BASAL_MANUAL)
                .or()
                .eq(VaultEntry.TYPE_FIELD_NAME, VaultEntryType.BASAL_PROFILE)
                .or()
                .eq(VaultEntry.TYPE_FIELD_NAME, VaultEntryType.BASAL_INTERPRETER)
                .and()
                .between(VaultEntry.TIMESTAMP_FIELD_NAME, from, to)
                .prepare();
        returnValues = vaultDao.query(query);
    } catch (SQLException ex) {
        LOG.log(Level.SEVERE, "Error while db query", ex);
    }
    return returnValues;
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:21,代码来源:VaultDao.java

示例8: queryGlucoseBetween

import com.j256.ormlite.stmt.PreparedQuery; //导入依赖的package包/类
/**
 * This method is used to query {@link VaultEntry}s which are of a given type and lie in a specified period.
 * The types to be queried for are glucose types:
 * <ul>
 *     <li>{@link VaultEntryType#GLUCOSE_BG}</li>
 *     <li>{@link VaultEntryType#GLUCOSE_CGM}</li>
 *     <li>{@link VaultEntryType#GLUCOSE_CGM_ALERT}</li>
 * </ul>
 *
 * @param from The start of the period to query entries from.
 * @param to The end of the period to query entries from.
 * @return All {@link VaultEntry} which are of the required type and lie in the specified period.
 */
//TODO OTHER TYPES? Let's ask Jens @next meeting
public List<VaultEntry> queryGlucoseBetween(final Date from, final Date to) {
    List<VaultEntry> returnValues = null;
    try {
        PreparedQuery<VaultEntry> query
                = vaultDao.queryBuilder().orderBy("timestamp", true)
                .where()
                .eq(VaultEntry.TYPE_FIELD_NAME, VaultEntryType.GLUCOSE_BG)
                .or()
                .eq(VaultEntry.TYPE_FIELD_NAME, VaultEntryType.GLUCOSE_CGM)
                .or()
                .eq(VaultEntry.TYPE_FIELD_NAME, VaultEntryType.GLUCOSE_CGM_ALERT)
                .and()
                .between(VaultEntry.TIMESTAMP_FIELD_NAME, from, to)
                .prepare();
        returnValues = vaultDao.query(query);
    } catch (SQLException exception) {
        LOG.log(Level.SEVERE, "Error while db query", exception);
    }
    return returnValues;
}
 
开发者ID:lucasbuschlinger,项目名称:BachelorPraktikum,代码行数:35,代码来源:VaultDao.java

示例9: queryExerciseBetween

import com.j256.ormlite.stmt.PreparedQuery; //导入依赖的package包/类
/**
 * This method is used to query {@link VaultEntry}s which are of a given type and lie in a specified period.
 * The types to be queried for are exercise types:
 * <ul>
 *     <li>{@link VaultEntryType#EXERCISE_BICYCLE}</li>
 *     <li>{@link VaultEntryType#EXERCISE_RUN}</li>
 *     <li>{@link VaultEntryType#EXERCISE_WALK}</li>
 *     <li>{@link VaultEntryType#EXERCISE_MANUAL}</li>
 * </ul>
 *
 * @param from The start of the period to query entries from.
 * @param to The end of the period to query entries from.
 * @return All {@link VaultEntry} which are of the required type and lie in the specified period.
 */
//TODO OTHER TYPES? Let's ask Jens @next meeting
public List<VaultEntry> queryExerciseBetween(final Date from, final Date to) {
    List<VaultEntry> returnValues = null;
    try {
        PreparedQuery<VaultEntry> query
                = vaultDao.queryBuilder().orderBy("timestamp", true)
                .where()
                .eq(VaultEntry.TYPE_FIELD_NAME, VaultEntryType.EXERCISE_BICYCLE)
                .or()
                .eq(VaultEntry.TYPE_FIELD_NAME, VaultEntryType.EXERCISE_RUN)
                .or()
                .eq(VaultEntry.TYPE_FIELD_NAME, VaultEntryType.EXERCISE_WALK)
                .or()
                .eq(VaultEntry.TYPE_FIELD_NAME, VaultEntryType.EXERCISE_MANUAL)
                .and()
                .between(VaultEntry.TIMESTAMP_FIELD_NAME, from, to)
                .prepare();
        returnValues = vaultDao.query(query);
    } catch (SQLException exception) {
        LOG.log(Level.SEVERE, "Error while db query", exception);
    }
    return returnValues;
}
 
开发者ID:lucasbuschlinger,项目名称:BachelorPraktikum,代码行数:38,代码来源:VaultDao.java

示例10: queryVaultEntryById

import com.j256.ormlite.stmt.PreparedQuery; //导入依赖的package包/类
/**
 * This is used to retrieve an entry from the database by its identifier.
 *
 * @param id The ID of the {@link VaultEntry} to be retrieved.
 * @return The {@link VaultEntry} with respective ID or null.
 */
public VaultEntry queryVaultEntryById(final long id) {
    List<VaultEntry> returnValues;
    try {
        PreparedQuery<VaultEntry> query
                = vaultDao.queryBuilder().orderBy("timestamp", true)
                .limit(1L)
                .where()
                .eq(VaultEntry.ID_FIELD_NAME, id)
                .prepare();
        returnValues = vaultDao.query(query);
    } catch (SQLException exception) {
        LOG.log(Level.SEVERE, "Error while db query", exception);
        return null;
    }
    return returnValues.get(0);
}
 
开发者ID:lucasbuschlinger,项目名称:BachelorPraktikum,代码行数:23,代码来源:VaultDao.java

示例11: queryVaultEntriesBetween

import com.j256.ormlite.stmt.PreparedQuery; //导入依赖的package包/类
/**
 * This is used to retrieve all {@link VaultEntry}s from the database which lie in the specified period of time, no matter their type.
 *
 * @param from The start of the time period to query entries from.
 * @param to The end of the time period to query entries from.
 * @return List of all {@link VaultEntry}s which lie in the specified time period.
 */
public List<VaultEntry> queryVaultEntriesBetween(final Date from, final Date to) {
    List<VaultEntry> returnValues = new ArrayList<>();
    try {
        Date fromTimestamp = TimestampUtils.createCleanTimestamp(from);
        Date toTimestamp = TimestampUtils.createCleanTimestamp(to);

        PreparedQuery<VaultEntry> query
                = vaultDao.queryBuilder().orderBy("timestamp", true)
                .where()
                .between(VaultEntry.TIMESTAMP_FIELD_NAME, fromTimestamp, toTimestamp)
                .prepare();
        returnValues = vaultDao.query(query);
    } catch (SQLException exception) {
        LOG.log(Level.SEVERE, "Error while db query", exception);
    }
    return returnValues;
}
 
开发者ID:lucasbuschlinger,项目名称:BachelorPraktikum,代码行数:25,代码来源:VaultDao.java

示例12: queryBasalBetween

import com.j256.ormlite.stmt.PreparedQuery; //导入依赖的package包/类
/**
 * This method is used to query {@link VaultEntry}s which are of a given type and lie in a specified period.
 * The types to be queried for are basal types:
 * <ul>
 *     <li>{@link VaultEntryType#BASAL_MANUAL}</li>
 *     <li>{@link VaultEntryType#BASAL_PROFILE}</li>
 *     <li>{@link VaultEntryType#BASAL_INTERPRETER}</li>
 * </ul>
 *
 * @param from The start of the period to query entries from.
 * @param to The end of the period to query entries from.
 * @return All {@link VaultEntry} which are of the required type and lie in the specified period.
 */
public List<VaultEntry> queryBasalBetween(final Date from, final Date to) {
    List<VaultEntry> returnValues = null;
    try {
        PreparedQuery<VaultEntry> query
                = vaultDao.queryBuilder().orderBy("timestamp", true)
                .where()
                .eq(VaultEntry.TYPE_FIELD_NAME, VaultEntryType.BASAL_MANUAL)
                .or()
                .eq(VaultEntry.TYPE_FIELD_NAME, VaultEntryType.BASAL_PROFILE)
                .or()
                .eq(VaultEntry.TYPE_FIELD_NAME, VaultEntryType.BASAL_INTERPRETER)
                .and()
                .between(VaultEntry.TIMESTAMP_FIELD_NAME, from, to)
                .prepare();
        returnValues = vaultDao.query(query);
    } catch (SQLException exception) {
        LOG.log(Level.SEVERE, "Error while db query", exception);
    }
    return returnValues;
}
 
开发者ID:lucasbuschlinger,项目名称:BachelorPraktikum,代码行数:34,代码来源:VaultDao.java

示例13: getTag

import com.j256.ormlite.stmt.PreparedQuery; //导入依赖的package包/类
public Tag getTag(final String aTag) {
    try {
        QueryBuilder<Tag, Long> queryBuilder = dbHelper.getTagDao().queryBuilder();
        Where<Tag, Long> where = queryBuilder.where();
        SelectArg selectArg = new SelectArg();

        // define our query as 'name = ?'
        where.eq(Tag.COLUMN_NAME_TITLE, selectArg);

        // prepare it so it is ready for later query or iterator calls
        PreparedQuery<Tag> preparedQuery = queryBuilder.prepare();

        // later we can set the select argument and issue the query
        selectArg.setValue(aTag);
        List<Tag> tgs = dbHelper.getTagDao().query(preparedQuery);
        if (!tgs.isEmpty()) {
            return tgs.get(0);
        }
    } catch (java.sql.SQLException pE) {
        pE.printStackTrace();
    }
    return null;
}
 
开发者ID:mrspaceman,项目名称:ebookmgr,代码行数:24,代码来源:LibraryManager.java

示例14: getBook

import com.j256.ormlite.stmt.PreparedQuery; //导入依赖的package包/类
public EBook getBook(final String fullFilename) {
    EBook ebk = null;
    try {
        QueryBuilder<EBook, Long> queryBuilder = dbHelper.getEBookDao().queryBuilder();
        Where<EBook, Long> where = queryBuilder.where();
        SelectArg selectArg = new SelectArg();

        // define our query as 'name = ?'
        where.eq(EBook.COLUMN_FULL_FILE_NAME, selectArg);

        // prepare it so it is ready for later query or iterator calls
        PreparedQuery<EBook> preparedQuery = queryBuilder.prepare();

        // later we can set the select argument and issue the query
        selectArg.setValue(fullFilename);
        List<EBook> result = dbHelper.getEBookDao().query(preparedQuery);

        if (result.size() > 0) {
            ebk = result.get(0);
        }
    } catch (java.sql.SQLException pE) {
        BookLibApplication.getInstance().e("Exception reading ebooks", pE);
    }
    return ebk;
}
 
开发者ID:mrspaceman,项目名称:ebookmgr,代码行数:26,代码来源:LibraryManager.java

示例15: getFileType

import com.j256.ormlite.stmt.PreparedQuery; //导入依赖的package包/类
public FileType getFileType(final String aFileType) {
    try {
        QueryBuilder<FileType, Long> queryBuilder = dbHelper.getFileTypeDao().queryBuilder();
        Where<FileType, Long> where = queryBuilder.where();
        SelectArg selectArg = new SelectArg();

        // define our query as 'name = ?'
        where.eq(FileType.COLUMN_NAME_TITLE, selectArg);

        // prepare it so it is ready for later query or iterator calls
        PreparedQuery<FileType> preparedQuery = queryBuilder.prepare();

        // later we can set the select argument and issue the query
        selectArg.setValue(aFileType);
        List<FileType> tgs = dbHelper.getFileTypeDao().query(preparedQuery);
        if (!tgs.isEmpty()) {
            return tgs.get(0);
        }
    } catch (java.sql.SQLException pE) {
        pE.printStackTrace();
    }
    return null;
}
 
开发者ID:mrspaceman,项目名称:ebookmgr,代码行数:24,代码来源:LibraryManager.java


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