为什么我尝试在表存储中创建表时出现以下错误:
com.microsoft.azure.storage.StorageException:确定 在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.CloudTable.exists(CloudTable.java:888) 在com.microsoft.azure.storage.table.CloudTable.createIfNotExists(CloudTable.java:290) 在com.microsoft.azure.storage.table.CloudTable.createIfNotExists(CloudTable.java:265) 在be.dela.gdprvault.test.StorageTestClient.getTableByName(StorageTestClient.groovy:25) 在be.dela.gdprvault.logging.entity.ActionLogSystemSpec.getActionLogFromTableByPartitionAndRowKey(ActionLogSystemSpec.groovy:114)处 在be.dela.gdprvault.logging.entity.ActionLogSystemSpec。应该将ActionLog实体保存到表存储中(ActionLogSystemSpec.groovy:96) 造成原因:java.lang.NullPointerException 在com.microsoft.azure.storage.table.TableDeserializer.parseJsonEntity(TableDeserializer.java:290) 在com.microsoft.azure.storage.table.TableDeserializer.parseSingleOpResponse(TableDeserializer.java:203) 在com.microsoft.azure.storage.table.QueryTableOperation.parseResponse(QueryTableOperation.java:143) 在com.microsoft.azure.storage.table.QueryTableOperation $ 1.postProcessResponse(QueryTableOperation.java:236) 在com.microsoft.azure.storage.table.QueryTableOperation $ 1.postProcessResponse(QueryTableOperation.java:193) 在com.microsoft.azure.storage.core.ExecutionEngine.executeWithRetry(ExecutionEngine.java:155) ...另外8个
int main() {
printf("\nThe size:\n");
unsigned n = 0;
scanf("%u",&n);
unsigned a[n];
for(unsigned i=0; i<n; i++) {
printf("a[%u] = ",i);
scanf("%d",&a[i]);
}
// Now test array
square_root_test_array(a, n);
return 0;
}
我确实根据文章https://docs.microsoft.com/en-us/azure/cosmos-db/table-storage-how-to-use-java
答案 0 :(得分:0)
我试图重现您的异常,但失败了。您可以使用Fiddler来捕获Java代码的请求和响应,以检查状态代码和错误详细信息。
您可以参考我的工作代码:
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版本是:
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-storage</artifactId>
<version>8.0.0</version>
</dependency>
希望它对您有帮助。