com.j256.ormlite.dao.Dao.executeRawNoArgs()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(2.8k)|赞(0)|评价(0)|浏览(187)

本文整理了Java中com.j256.ormlite.dao.Dao.executeRawNoArgs()方法的一些代码示例,展示了Dao.executeRawNoArgs()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Dao.executeRawNoArgs()方法的具体详情如下:
包路径:com.j256.ormlite.dao.Dao
类名称:Dao
方法名:executeRawNoArgs

Dao.executeRawNoArgs介绍

[英]Run a raw execute SQL statement on the database without any arguments. This may use a different mechanism to execute the query depending on the database backend.
[中]在数据库上运行原始的execute SQL语句,不带任何参数。这可能会使用不同的机制来执行查询,具体取决于数据库后端。

代码示例

代码示例来源:origin: j256/ormlite-core

/**
 * @see Dao#executeRawNoArgs(String)
 */
@Override
public int executeRawNoArgs(String statement) {
  try {
    return dao.executeRawNoArgs(statement);
  } catch (SQLException e) {
    logMessage(e, "executeRawNoArgs threw exception on: " + statement);
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: com.j256.ormlite/ormlite-core

/**
 * @see Dao#executeRawNoArgs(String)
 */
@Override
public int executeRawNoArgs(String statement) {
  try {
    return dao.executeRawNoArgs(statement);
  } catch (SQLException e) {
    logMessage(e, "executeRawNoArgs threw exception on: " + statement);
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: annmuor/jnode

public void executeRaw(String query) {
  try {
    getDao().executeRawNoArgs(query);
  } catch (SQLException e) {
    logger.l1("SQL Exception in executeRaw", e);
    logger.l1(MessageFormat.format("we worked with {0}", query));
  }
}

代码示例来源:origin: j256/ormlite-core

@Test
public void testExecuteRawNoArgs() throws Exception {
  @SuppressWarnings("unchecked")
  Dao<Foo, String> dao = (Dao<Foo, String>) createMock(Dao.class);
  RuntimeExceptionDao<Foo, String> rtDao = new RuntimeExceptionDao<Foo, String>(dao);
  expect(dao.executeRawNoArgs(null)).andReturn(0);
  replay(dao);
  rtDao.executeRawNoArgs(null);
  verify(dao);
}

代码示例来源:origin: j256/ormlite-core

@Test(expected = RuntimeException.class)
public void testExecuteRawNoArgsThrow() throws Exception {
  @SuppressWarnings("unchecked")
  Dao<Foo, String> dao = (Dao<Foo, String>) createMock(Dao.class);
  RuntimeExceptionDao<Foo, String> rtDao = new RuntimeExceptionDao<Foo, String>(dao);
  expect(dao.executeRawNoArgs(null)).andThrow(new SQLException("Testing catch"));
  replay(dao);
  rtDao.executeRawNoArgs(null);
  verify(dao);
}

代码示例来源:origin: ChestShop-authors/ChestShop-3

private static boolean migrateTo3() {
  try {
    Dao<Account, String> accountsOld = DaoCreator.getDao(Account.class);
    accountsOld.executeRawNoArgs("ALTER TABLE `accounts` RENAME TO `accounts-old`");
      accounts.executeRawNoArgs("INSERT INTO `accounts` (name, shortName, uuid) SELECT name, shortName, uuid FROM `accounts-old`");
    } catch (SQLException e) {
      ChestShop.getBukkitLogger().log(Level.WARNING, "Fast accounts migration failed!\n" + e + "\nCause: " + e.getCause());
      ChestShop.getBukkitLogger().log(Level.INFO, "Starting slow migration...");
      accounts.executeRawNoArgs("DELETE FROM `accounts`");

相关文章