本文整理汇总了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();
}
}