gpt4 book ai didi

java - 微软Azure表存储: CloudTable() error no suggestions available

转载 作者:行者123 更新时间:2023-11-30 10:35:34 24 4
gpt4 key购买 nike

我正在使用 Java 中的 Azure 表存储,遵循教程 here 。我成功地创建了一个表、添加了一个实体、检索了一个实体并删除了一个实体。但是,我有这个方法来删除表:

public void deleteTable(String tableName) {
try {
CloudStorageAccount storageAccount = CloudStorageAccount.parse(storageConnectionString);
CloudTableClient tableClient = storageAccount.createCloudTableClient();

// Delete the table and all its data if it exists.
CloudTable cloudTable = new CloudTable(tableName, tableClient);

cloudTable.deleteIfExists();
} catch (Exception e) {
System.out.println("Error in deleting");
e.printStackTrace();
}
}

在此方法中,我在该行收到错误

CloudTable cloudTable = new CloudTable(tableName, tableClient);

在 Eclipse 中没有可用的建议,只有以下标记:

Multiple markers at this line

  • The constructor CloudTable(String, CloudTableClient) is not visible
  • The constructor CloudTable(String, CloudTableClient) is not visible

任何帮助将不胜感激。

最佳答案

如果你看看CloudTable构造函数here ,您会注意到您使用的代码不是有效的。 SDK 可能已升级,但代码示例并未升级。我建议使用getTableReference方法CloudTableClient获取 CloudTable 的实例:

try
{
// Retrieve storage account from connection-string.
CloudStorageAccount storageAccount =
CloudStorageAccount.parse(storageConnectionString);

// Create the table client.
CloudTableClient tableClient = storageAccount.createCloudTableClient();

// Delete the table and all its data if it exists.
CloudTable cloudTable = tableClient.getTableReference("people");
cloudTable.deleteIfExists();
}
catch (Exception e)
{
// Output the stack trace.
e.printStackTrace();
}

关于java - 微软Azure表存储: CloudTable() error no suggestions available,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41077314/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com