我尝试在网络上搜索任何其他方式/功能,结果是:
public static boolean isTableExist(Table table){
try {
table.describe();
} catch (ResourceNotFoundException e) {
return false;
}
return true;
}
有没有机会摆脱try catch?
最佳答案
是的,如果您只想检查表是否存在,那就是这样。但是,如果您打算创建不存在的表,则可以使用 API:TableUtils#createTableIfNotExists
关于java - 这是检查 DynamoDB 表是否存在的最佳实践吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41042659/