首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如果不存在java创建表,则创建表存储

如果不存在java创建表,则创建表存储
EN

Stack Overflow用户
提问于 2018-10-31 17:59:45
回答 1查看 716关注 0票数 2

当我尝试在表存储中创建表时,为什么会出现以下错误:

com.microsoft.azure.storage.StorageException.translateException(StorageException.java:87),com.microsoft.azure.storage.core.ExecutionEngine.executeWithRetry(ExecutionEngine.java:209),com.microsoft.azure.storage.table.QueryTableOperation.performRetrieve(QueryTableOperation.java:178),com.microsoft.azure.storage.table.TableOperation.execute(TableOperation.java:694),com.microsoft.azure.storage.table.CloudTablecom.microsoft.azure.storage.table.CloudTable.createIfNotExists(CloudTable.java:290) at com.microsoft.azure.storage.table.CloudTable.createIfNotExists(CloudTable.java:265) be.dela.gdprvault.test.StorageTestClient.getTableByName(StorageTestClient.groovy:25) at be.dela.gdprvault.logging.entity.ActionLogSystemSpec.getActionLogFromTableByPartitionAndRowKey(ActionLogSystemSpec.groovy:114) at be.dela.gdprvault.logging.entity.ActionLogSystemSpec.should .exists(CloudTable.java:888)将com.microsoft.azure.storage.table.TableDeserializer.parseJsonEntity(TableDeserializer.java:290)的ActionLog实体保存到表存储(ActionLogSystemSpec.groovy:96)中,这是由: java.lang.NullPointerException at ActionLog at com.microsoft.azure.storage.table.QueryTableOperation.parseResponse(QueryTableOperation.java:143) at com.microsoft.azure.storage.table.QueryTableOperation$1.postProcessResponse(QueryTableOperation.java:236)引起的在com.microsoft.azure.storage.table.QueryTableOperation$1.postProcessResponse(QueryTableOperation.java:193) at com.microsoft.azure.storage.core.ExecutionEngine.executeWithRetry(ExecutionEngine.java:155) .还有8家

代码语言:javascript
复制
docer-compose
  azure-blob-storage:
    image: arafato/azurite
    ports:
      - "10000:10000"
      - "10002:10002"
    volumes:
      - data-volume:/opt/azurite/folder

    CloudTable table = tableClient.getTableReference(tableName)
    table.createIfNotExists() -- there is error

我是按照https://learn.microsoft.com/en-us/azure/cosmos-db/table-storage-how-to-use-java的文章写的

EN

回答 1

Stack Overflow用户

发布于 2018-11-01 06:53:32

我试图复制你的例外,但失败了。您可以使用费德勒捕获java代码的请求和响应,以检查状态代码和错误详细信息。

您可以参考我的工作代码:

代码语言:javascript
复制
import com.microsoft.azure.storage.*;
import com.microsoft.azure.storage.table.*;

public class CreateTableTest {

    public static final String storageConnectionString =
            "DefaultEndpointsProtocol=https;" +
                    "AccountName=***;" +
                    "AccountKey=***;" +
                    "TableEndpoint=https://***.table.cosmosdb.azure.com:443/;" ;

    public static void main(String[] args) {

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

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

            // Create the table if it doesn't exist.
            String tableName = "people";
            CloudTable cloudTable = tableClient.getTableReference(tableName);
            cloudTable.createIfNotExists();

            System.out.println("Create Success...");
        }
        catch (Exception e)
        {
            // Output the stack trace.
            e.printStackTrace();
        }

    }
}

我的sdk版本是:

代码语言:javascript
复制
<dependency>
   <groupId>com.microsoft.azure</groupId>
   <artifactId>azure-storage</artifactId>
   <version>8.0.0</version>
</dependency>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53089470

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档