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

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

本文整理了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

  1. /**
  2. * @see Dao#executeRawNoArgs(String)
  3. */
  4. @Override
  5. public int executeRawNoArgs(String statement) {
  6. try {
  7. return dao.executeRawNoArgs(statement);
  8. } catch (SQLException e) {
  9. logMessage(e, "executeRawNoArgs threw exception on: " + statement);
  10. throw new RuntimeException(e);
  11. }
  12. }

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

  1. /**
  2. * @see Dao#executeRawNoArgs(String)
  3. */
  4. @Override
  5. public int executeRawNoArgs(String statement) {
  6. try {
  7. return dao.executeRawNoArgs(statement);
  8. } catch (SQLException e) {
  9. logMessage(e, "executeRawNoArgs threw exception on: " + statement);
  10. throw new RuntimeException(e);
  11. }
  12. }

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

  1. public void executeRaw(String query) {
  2. try {
  3. getDao().executeRawNoArgs(query);
  4. } catch (SQLException e) {
  5. logger.l1("SQL Exception in executeRaw", e);
  6. logger.l1(MessageFormat.format("we worked with {0}", query));
  7. }
  8. }

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

  1. @Test
  2. public void testExecuteRawNoArgs() throws Exception {
  3. @SuppressWarnings("unchecked")
  4. Dao<Foo, String> dao = (Dao<Foo, String>) createMock(Dao.class);
  5. RuntimeExceptionDao<Foo, String> rtDao = new RuntimeExceptionDao<Foo, String>(dao);
  6. expect(dao.executeRawNoArgs(null)).andReturn(0);
  7. replay(dao);
  8. rtDao.executeRawNoArgs(null);
  9. verify(dao);
  10. }

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

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

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

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

相关文章