本文整理汇总了Java中com.dsh105.echopet.compat.api.plugin.uuid.UUIDFetcher.getUUIDOf方法的典型用法代码示例。如果您正苦于以下问题:Java UUIDFetcher.getUUIDOf方法的具体用法?Java UUIDFetcher.getUUIDOf怎么用?Java UUIDFetcher.getUUIDOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.dsh105.echopet.compat.api.plugin.uuid.UUIDFetcher
的用法示例。
在下文中一共展示了UUIDFetcher.getUUIDOf方法的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();
}
}