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

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

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

Dao.isTableExists介绍

[英]Returns true if the table already exists otherwise false.
[中]如果表已存在,则返回true,否则返回false。

代码示例

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

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

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

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

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

  1. protected GenericDAO() throws Exception {
  2. if (daoMap == null) {
  3. daoMap = new HashMap<>();
  4. }
  5. if (!daoMap.containsKey(getType())) {
  6. Dao<?, ?> dao = DaoManager.createDao(ORMManager.getSource(),
  7. getType());
  8. if (!dao.isTableExists()) {
  9. TableUtils.createTable(ORMManager.getSource(), getType());
  10. }
  11. daoMap.put(getType(), dao);
  12. }
  13. }

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

  1. @Test(expected = RuntimeException.class)
  2. public void testIsTableExistsThrow() 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.isTableExists()).andThrow(new SQLException("Testing catch"));
  7. replay(dao);
  8. rtDao.isTableExists();
  9. verify(dao);
  10. }

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

  1. @Test
  2. public void testIsTableExists() throws Exception {
  3. Dao<TableExists, Integer> dao = createDao(TableExists.class, false);
  4. assertFalse(dao.isTableExists());
  5. TableUtils.createTable(connectionSource, TableExists.class);
  6. assertTrue(dao.isTableExists());
  7. TableUtils.dropTable(connectionSource, TableExists.class, true);
  8. assertFalse(dao.isTableExists());
  9. }

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

  1. @Test
  2. public void testTableExists() throws Exception {
  3. Dao<Foo, Integer> dao = createDao(Foo.class, false);
  4. assertFalse(dao.isTableExists());
  5. TableUtils.createTable(connectionSource, Foo.class);
  6. assertTrue(dao.isTableExists());
  7. TableUtils.dropTable(connectionSource, Foo.class, false);
  8. assertFalse(dao.isTableExists());
  9. }

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

  1. @Test(expected = SQLException.class)
  2. public void testIsTableExistsThrow() throws Exception {
  3. Dao<Foo, Integer> dao = createDao(Foo.class, true);
  4. Foo foo = new Foo();
  5. assertEquals(1, dao.create(foo));
  6. DatabaseConnection conn = connectionSource.getReadWriteConnection(FOO_TABLE_NAME);
  7. try {
  8. conn.close();
  9. dao.isTableExists();
  10. } finally {
  11. connectionSource.releaseConnection(conn);
  12. }
  13. }

相关文章