为什么Bluemix dashDB操作会抛出SQLCODE = -1667的SqlSyntaxErrorException?

时间:2015-08-19 00:09:27

标签: java database ibm-cloud dashdb

即使我没有尝试编辑表格/列,我也收到此错误:

  

com.ibm.db2.jcc.am.SqlSyntaxErrorException:操作失败,因为指定表的类型不支持该操作。指定表:" DASH103985.wajihs"。表类型:"按柱子组织"。操作:"使用RS" .. SQLCODE = -1667,SQLSTATE = 42858

@MultipartConfig
public class DemoServlet extends HttpServlet {
  private static Logger logger = Logger.getLogger(DemoServlet.class.getName());
  private static final long serialVersionUID = 1L;
  @Resource(lookup="jdbc/db2")DataSource dataSource;

private String getDefaultText() {
  TweetsCombined = new String(" ");
  try {
    // Connect to the Database
    Connection con = null;
    try {
      System.out.println("Connecting to the database");
    } catch (SQLException e) {
      TweetsCombined = "first" +e;
    }

    // Try out some dynamic SQL Statements
    Statement stmt = null;

  try {
    stmt = con.createStatement();
    String tableName = "wajihs";// change table name here to one
                  // chosen in the first website
    String columnName = "msgBody";// msgBody is where the tweets
                                          // are stored
    String query = "SELECT * FROM \"" + tableName + "\"";
    ResultSet rs = stmt.executeQuery(query);

    while (rs.next()) {
      content = rs.getString(columnName) + ". ";
      if (content.toLowerCase().contains("RT".toLowerCase())
              || content.toLowerCase().contains("Repost: ".toLowerCase())) {
        // do nothing
      }
      else {
        TweetsCombined.concat(content);
      }

    }
    // Close everything off
    // Close the Statement
    stmt.close();
    // close
    con.commit();
    // Close the connection
    con.close();
  } catch (Exception e) {
    TweetsCombined = "second" +e;
    System.out.println(e.getMessage());
  }
} catch (Exception e) {
  TweetsCombined = "third" + e;
  System.out.println(e);
}
return TweetsCombined;

}

1 个答案:

答案 0 :(得分:3)

正如我解释here,与没有BLU Acceleration的DB2相比,具有BLU Acceleration功能的dashDB具有一定的局限性。在您的情况下,您只能针对列组织表运行具有CS隔离级别的查询。

更改连接配置以使用CS隔离级别或在明确指定ORGANIZE BY ROW时创建表。