自 2025 年 11 月 1 日起,Amazon Redshift 將不再支援建立新的 Python UDFs。如果您想要使用 Python UDFs,請在該日期之前建立 UDFs。現有的 Python UDFs將繼續如常運作。如需詳細資訊,請參閱部落格文章 。
本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
ListDatabases
搭配 AWS SDK 使用
以下程式碼範例顯示如何使用 ListDatabases
。
- Java
-
- 適用於 Java 2.x 的 SDK
-
/**
* Lists all databases asynchronously for the specified cluster, database user, and database.
* @param clusterId the identifier of the cluster to list databases for
* @param dbUser the database user to use for the list databases request
* @param database the database to list databases for
* @return a {@link CompletableFuture} that completes when the database listing is complete, or throws a {@link RuntimeException} if there was an error
*/
public CompletableFuture<Void> listAllDatabasesAsync(String clusterId, String dbUser, String database) {
ListDatabasesRequest databasesRequest = ListDatabasesRequest.builder()
.clusterIdentifier(clusterId)
.dbUser(dbUser)
.database(database)
.build();
// Asynchronous paginator for listing databases.
ListDatabasesPublisher databasesPaginator = getAsyncDataClient().listDatabasesPaginator(databasesRequest);
CompletableFuture<Void> future = databasesPaginator.subscribe(response -> {
response.databases().forEach(db -> {
logger.info("The database name is {} ", db);
});
});
// Return the future for asynchronous handling.
return future.exceptionally(exception -> {
throw new RuntimeException("Failed to list databases: " + exception.getMessage(), exception);
});
}
如需 AWS SDK 開發人員指南和程式碼範例的完整清單,請參閱 搭配 AWS SDK 使用此服務。此主題也包含有關入門的資訊和舊版 SDK 的詳細資訊。