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


Java TableUtils类代码示例

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


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

示例1: createTable

import com.j256.ormlite.table.TableUtils; //导入依赖的package包/类
private void createTable(SQLiteDatabase db, ConnectionSource connectionSource) {
    try {
        TableUtils.createTable(connectionSource, MyPhoto.class);
        TableUtils.createTable(connectionSource, MyMoment.class);
        TableUtils.createTable(connectionSource, MyMomentPhoto.class);
        TableUtils.createTable(connectionSource, MyFace.class);
        TableUtils.createTable(connectionSource, MyFacePhoto.class);
        TableUtils.createTable(connectionSource, UploadedPhoto.class);
        TableUtils.createTable(connectionSource, MyAlbum.class);
        TableUtils.createTable(connectionSource, MyAlbumPhoto.class);
        TableUtils.createTable(connectionSource, MyTag.class);
        TableUtils.createTable(connectionSource, MyTagPhoto.class);
        TableUtils.createTable(connectionSource, MyCursor.class);
        TableUtils.createTable(connectionSource, MySetting.class);
    } catch (Exception e) {
        Log.e(DatabaseHelper.class.getName(), "Can't create database", e);
        e.printStackTrace();
    }
}
 
开发者ID:aliyun,项目名称:aliyun-cloudphotos-android-demo,代码行数:20,代码来源:DatabaseHelper.java

示例2: updateTable

import com.j256.ormlite.table.TableUtils; //导入依赖的package包/类
private void updateTable(SQLiteDatabase db, ConnectionSource connectionSource, int oldVersion, int newVersion) {
    try {
        TableUtils.dropTable(connectionSource, MyPhoto.class, true);
        TableUtils.dropTable(connectionSource, MyMoment.class, true);
        TableUtils.dropTable(connectionSource, MyMomentPhoto.class, true);
        TableUtils.dropTable(connectionSource, MyFace.class, true);
        TableUtils.dropTable(connectionSource, MyFacePhoto.class, true);
        TableUtils.dropTable(connectionSource, UploadedPhoto.class, true);
        TableUtils.dropTable(connectionSource, MyAlbum.class, true);
        TableUtils.dropTable(connectionSource, MyAlbumPhoto.class, true);
        TableUtils.dropTable(connectionSource, MyTag.class, true);
        TableUtils.dropTable(connectionSource, MyTagPhoto.class, true);
        TableUtils.dropTable(connectionSource, MyCursor.class, true);
        TableUtils.dropTable(connectionSource, MySetting.class, true);
        onCreate(db, connectionSource);
    } catch (Exception e) {
        Log.e(DatabaseHelper.class.getName(), "Can't drop databases", e);
        throw new RuntimeException(e);
    }
}
 
开发者ID:aliyun,项目名称:aliyun-cloudphotos-android-demo,代码行数:21,代码来源:DatabaseHelper.java

示例3: onCreate

import com.j256.ormlite.table.TableUtils; //导入依赖的package包/类
@Override
public void onCreate(SQLiteDatabase database, ConnectionSource connectionSource) {

    try {
        TableUtils.createTable(connectionSource, AirQualityLive.class);
        TableUtils.createTable(connectionSource, WeatherForecast.class);
        TableUtils.createTable(connectionSource, LifeIndex.class);
        TableUtils.createTable(connectionSource, WeatherLive.class);
        TableUtils.createTable(connectionSource, Weather.class);

        String weatherTrigger = "CREATE TRIGGER trigger_delete AFTER DELETE " +
                "ON Weather " +
                "FOR EACH ROW " +
                "BEGIN " +
                "DELETE FROM AirQuality WHERE cityId = OLD.cityId; " +
                "DELETE FROM WeatherLive WHERE cityId = OLD.cityId; " +
                "DELETE FROM WeatherForecast WHERE cityId = OLD.cityId; " +
                "DELETE FROM LifeIndex WHERE cityId = OLD.cityId; " +
                "END;";
        database.execSQL(weatherTrigger);

    } catch (SQLException e) {
        e.printStackTrace();
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:WeatherDatabaseHelper.java

示例4: initDb

import com.j256.ormlite.table.TableUtils; //导入依赖的package包/类
private void initDb() throws SQLException {
        // create a connection source to our database
        connectionSource = new JdbcConnectionSource(DATABASE_URL, "sa", "",
                new HsqldbDatabaseType());
        // instantiate the DAO 
        vaultDao = DaoManager.createDao(connectionSource, VaultEntry.class);
        if (!vaultDao.isTableExists()) {
            TableUtils.createTableIfNotExists(connectionSource, VaultEntry.class);
        } else {
            LOG.warning("Found existing DB for VaultEntries. Reusing it!!");
        }

        rawDao = DaoManager.createDao(connectionSource, RawEntry.class);
        if (!rawDao.isTableExists()) {
            TableUtils.createTableIfNotExists(connectionSource, RawEntry.class);
        }
//        TableUtils.createTableIfNotExists(connectionSource, SliceEntry.class);
    }
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:19,代码来源:VaultDao.java

示例5: AbstractDaoService

import com.j256.ormlite.table.TableUtils; //导入依赖的package包/类
public AbstractDaoService(Class clazz, SpringConfiguration configuration) {

        try {
            this.clazz = clazz;

            // TODO: let user create it's own database
            connection = DatabaseUtils.getH2OrmliteConnectionPool(configuration.getDatabasePath(),
                    // please do not laugh :)
                    SpringConfiguration.DB_LOGIN, SpringConfiguration.DB_PASSWORD);

            TableUtils.createTableIfNotExists(connection, clazz);

            // instantiate the dao
            dao = DaoManager.createDao(connection, clazz);

        } catch (SQLException e) {
            throw new IllegalStateException(e);
        }
    }
 
开发者ID:remipassmoilesel,项目名称:simple-hostel-management,代码行数:20,代码来源:AbstractDaoService.java

示例6: onCreate

import com.j256.ormlite.table.TableUtils; //导入依赖的package包/类
/**
 * 创建数据库时会回调的接口,在这个方法里面完成对数据库表的创建
 */
@Override
public void onCreate(SQLiteDatabase db, ConnectionSource connectionSource)
{
	try
	{
		Log.I(TAG, "--------------------- onCreate ---------------------");
		
		TableUtils.createTable(connectionSource, Like.class);
		
		// 数据初始化
		initDatabase(db, connectionSource);
	}
	catch (SQLException e)
	{
		Log.E(TAG, "Can't create database.", e);
		throw new RuntimeException(e);
	}
	
}
 
开发者ID:benniaobuguai,项目名称:android-project-gallery,代码行数:23,代码来源:LocalDbCacheHelper.java

示例7: onCreate

import com.j256.ormlite.table.TableUtils; //导入依赖的package包/类
/**
 * 创建数据库时会回调的接口,在这个方法里面完成对数据库表的创建
 */
@Override
public void onCreate(SQLiteDatabase db, ConnectionSource connectionSource) {
	try {
		Log.I(TAG, "--------------------- onCreate ---------------------");

		TableUtils.createTable(connectionSource, AlbumInfo.class);
		TableUtils.createTable(connectionSource, PhotoInfo.class);

		// 数据初始化
		initDatabase(db, connectionSource);
	} catch (SQLException e) {
		Log.E(TAG, "Can't create database.", e);
		throw new RuntimeException(e);
	}

}
 
开发者ID:benniaobuguai,项目名称:android-project-gallery,代码行数:20,代码来源:DatabaseHelper.java

示例8: onUpgrade

import com.j256.ormlite.table.TableUtils; //导入依赖的package包/类
/**
 * 处理数据库版本升级
 */
@Override
public void onUpgrade(SQLiteDatabase db, ConnectionSource connectionSource, int oldVersion, int newVersion) {
	Log.I(TAG, "--------------------- onUpgrade ---------------------");
	int version = oldVersion;
	if (version < 4) {
		upgradeFor2(db);
		version = 3;
	}

	if (version != DATABASE_VERSION) {
		Log.W(TAG, "Destroying all old data.");
		try {
			Log.I(TAG, "--------------------- onUpgrade ---------------------");

			TableUtils.dropTable(connectionSource, AlbumInfo.class, true);
			TableUtils.dropTable(connectionSource, PhotoInfo.class, true);

			onCreate(db, connectionSource);
		} catch (SQLException e) {
			Log.E(TAG, "Can't drop databases", e);
			throw new RuntimeException(e);
		}
	}

}
 
开发者ID:benniaobuguai,项目名称:android-project-gallery,代码行数:29,代码来源:DatabaseHelper.java

示例9: initDb

import com.j256.ormlite.table.TableUtils; //导入依赖的package包/类
/**
     * Initializes the actual database as a {@link JdbcConnectionSource}.
     *
     * @throws SQLException Thrown if the database can not be successfully initialized.
     */
    private void initDb() throws SQLException {
        // create a connection source to our database
        connectionSource = new JdbcConnectionSource(DATABASE_URL, "sa", "",
                new HsqldbDatabaseType());
        // instantiate the DAO
        vaultDao = DaoManager.createDao(connectionSource, VaultEntry.class);
        if (!vaultDao.isTableExists()) {
            TableUtils.createTableIfNotExists(connectionSource, VaultEntry.class);
        } else {
            LOG.warning("Found existing DB for VaultEntries. Reusing it!!");
        }

        rawDao = DaoManager.createDao(connectionSource, RawEntry.class);
        if (!rawDao.isTableExists()) {
            TableUtils.createTableIfNotExists(connectionSource, RawEntry.class);
        }
//        TableUtils.createTableIfNotExists(connectionSource, SliceEntry.class);
    }
 
开发者ID:lucasbuschlinger,项目名称:BachelorPraktikum,代码行数:24,代码来源:VaultDao.java

示例10: onUpgrade

import com.j256.ormlite.table.TableUtils; //导入依赖的package包/类
/**
 * This is called when your application is upgraded and it has a higher version number. This allows you to adjust
 * the various data to match the new version number.
 */
@Override
public void onUpgrade(SQLiteDatabase db, ConnectionSource connectionSource, int oldVersion, int newVersion) {
    try {
        Log.i(TAG, "onUpgrade");
        TableUtils.dropTable(connectionSource, SuspectedApp.class, true);
        Log.d(TAG, String.format("Dropped suspected app table!"));
        Dao<WhiteEntry, Integer> whiteListDao = getWhiteListDao();
        DeleteBuilder<WhiteEntry, Integer> deleteBuilder = whiteListDao.deleteBuilder();
        deleteBuilder.where().eq("systemEntry", Boolean.TRUE);
        int deleted = deleteBuilder.delete();
        Log.d(TAG, String.format("Delete %d old system whitelist entries", deleted));
        onCreate(db, connectionSource);
    } catch (SQLException e) {
        Log.e(TAG, "Can't drop databases", e);
        throw new RuntimeException(e);
    }
}
 
开发者ID:geeksonsecurity,项目名称:android-overlay-protection,代码行数:22,代码来源:DatabaseHelper.java

示例11: onUpgrade

import com.j256.ormlite.table.TableUtils; //导入依赖的package包/类
@Override
public void onUpgrade(SQLiteDatabase database, ConnectionSource connectionSource, int oldVersion, int newVersion) {
    try {
        TableUtils.dropTable(connectionSource, EventGuestOutfitItem.class, false);
        TableUtils.dropTable(connectionSource, EventGuestOutfit.class, false);
        TableUtils.dropTable(connectionSource, EventGuest.class, false);
        TableUtils.dropTable(connectionSource, Event.class, false);
        TableUtils.dropTable(connectionSource, Item.class, false);
        TableUtils.dropTable(connectionSource, User.class, false);
        TableUtils.dropTable(connectionSource, Photo.class, false);

        onCreate(database, connectionSource);
    } catch (SQLException e) {
        e.printStackTrace();
    }
}
 
开发者ID:joeydeluca,项目名称:apparel,代码行数:17,代码来源:OrmLiteSqlHelper.java

示例12: onCreate

import com.j256.ormlite.table.TableUtils; //导入依赖的package包/类
@Override
public void onCreate(SQLiteDatabase database, ConnectionSource connectionSource) {
    try {
        log.info("onCreate");
        TableUtils.createTableIfNotExists(connectionSource, TempTarget.class);
        TableUtils.createTableIfNotExists(connectionSource, Treatment.class);
        TableUtils.createTableIfNotExists(connectionSource, BgReading.class);
        TableUtils.createTableIfNotExists(connectionSource, DanaRHistoryRecord.class);
        TableUtils.createTableIfNotExists(connectionSource, DbRequest.class);
        TableUtils.createTableIfNotExists(connectionSource, TemporaryBasal.class);
        TableUtils.createTableIfNotExists(connectionSource, ExtendedBolus.class);
        TableUtils.createTableIfNotExists(connectionSource, CareportalEvent.class);
        TableUtils.createTableIfNotExists(connectionSource, ProfileSwitch.class);
        TableUtils.createTableIfNotExists(connectionSource, Food.class);
    } catch (SQLException e) {
        log.error("Can't create database", e);
        throw new RuntimeException(e);
    }
}
 
开发者ID:MilosKozak,项目名称:AndroidAPS,代码行数:20,代码来源:DatabaseHelper.java

示例13: onUpgrade

import com.j256.ormlite.table.TableUtils; //导入依赖的package包/类
@Override
public void onUpgrade(SQLiteDatabase database, ConnectionSource connectionSource, int oldVersion, int newVersion) {
    try {
        if (oldVersion == 7 && newVersion == 8) {
            log.debug("Upgrading database from v7 to v8");
            TableUtils.dropTable(connectionSource, Treatment.class, true);
            TableUtils.createTableIfNotExists(connectionSource, Treatment.class);
        } else {
            log.info(DatabaseHelper.class.getName(), "onUpgrade");
            TableUtils.dropTable(connectionSource, TempTarget.class, true);
            TableUtils.dropTable(connectionSource, Treatment.class, true);
            TableUtils.dropTable(connectionSource, BgReading.class, true);
            TableUtils.dropTable(connectionSource, DanaRHistoryRecord.class, true);
            TableUtils.dropTable(connectionSource, DbRequest.class, true);
            TableUtils.dropTable(connectionSource, TemporaryBasal.class, true);
            TableUtils.dropTable(connectionSource, ExtendedBolus.class, true);
            TableUtils.dropTable(connectionSource, CareportalEvent.class, true);
            TableUtils.dropTable(connectionSource, ProfileSwitch.class, true);
            TableUtils.dropTable(connectionSource, Food.class, true);
            onCreate(database, connectionSource);
        }
    } catch (SQLException e) {
        log.error("Can't drop databases", e);
        throw new RuntimeException(e);
    }
}
 
开发者ID:MilosKozak,项目名称:AndroidAPS,代码行数:27,代码来源:DatabaseHelper.java

示例14: onCreate

import com.j256.ormlite.table.TableUtils; //导入依赖的package包/类
@Override
public void onCreate(SQLiteDatabase database, final ConnectionSource connectionSource)
{
    try
    {
        setupClasses();
        PFALogger.debug(getClass().getName(), ON_CREATE, START);
        for ( Class aClass : entityClasses )
        {
            TableUtils.createTable(connectionSource, aClass);
        }
    }
    catch ( Exception e )
    {
        PFALogger.error(getClass().getName(), ON_CREATE, e);
    }
}
 
开发者ID:SecUSo,项目名称:privacy-friendly-shopping-list,代码行数:18,代码来源:DataBaseHelper.java

示例15: onUpgrade

import com.j256.ormlite.table.TableUtils; //导入依赖的package包/类
@Override
public void onUpgrade(SQLiteDatabase database, ConnectionSource connectionSource, int oldVersion, int newVersion)
{
    try
    {
        setupClasses();
        for ( Class aClass : entityClasses )
        {
            TableUtils.dropTable(connectionSource, aClass, true);
        }
        onCreate(database, connectionSource);
    }
    catch ( SQLException e )
    {
        PFALogger.error(getClass().getName(), ON_UPGRADE, e);
    }
}
 
开发者ID:SecUSo,项目名称:privacy-friendly-shopping-list,代码行数:18,代码来源:DataBaseHelper.java


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