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


Java UUIDFetcher类代码示例

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


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

示例1: migrate

import com.dsh105.echopet.compat.api.plugin.uuid.UUIDFetcher; //导入依赖的package包/类
@Override
public void migrate(Connection conn) throws SQLException {
    // Copy all of our data over to the new table
    PreparedStatement copyStatement = conn.prepareStatement("INSERT INTO EchoPet SELECT * FROM Pets");
    copyStatement.executeUpdate();

    // Migrate to UUIDs in the new table if necessary
    if (ReflectionUtil.MC_VERSION_NUMERIC >= 172 && UUIDMigration.supportsUuid()) {
        PreparedStatement getOwnerStatement = conn.prepareStatement("SELECT OwnerName FROM EchoPet");

        PreparedStatement updateNameStatement = conn.prepareStatement("UPDATE EchoPet SET OwnerName = ? WHERE OwnerName = ?");
        ResultSet resultSet = getOwnerStatement.executeQuery();
        while (resultSet.next()) {
            String ownerName = resultSet.getString("OwnerName");

            try {
                UUID.fromString(ownerName);
                continue; // This name is already a UUID.
            } catch (IllegalArgumentException ignored) {
            }

            UUID playerUUID;
            try {
                playerUUID = UUIDFetcher.getUUIDOf(ownerName);
            } catch (Exception e) {
                continue;
            }

            if (playerUUID == null) {
                continue;
            }

            updateNameStatement.setString(1, playerUUID.toString());
            updateNameStatement.setString(2, ownerName);
            updateNameStatement.addBatch();
        }

        updateNameStatement.executeBatch();
    }
}
 
开发者ID:Borlea,项目名称:EchoPet,代码行数:41,代码来源:TableMigrationUtil.java


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