2015-08-19 42 views
1

我越來越即使我不是要編輯表/列此錯誤:爲什麼Bluemix dashDB操作拋出SQLCODE = -1667的SqlSyntaxErrorException?

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; 

}

+0

您是否查找了SQLCODE和SQLSTATE值的文檔?你能告訴我們在那個源文件中的異常被觸發的地方嗎?你試過什麼了? – nitind

回答

3

正如我解釋here,dashDB,其BLU加速功能,具有一定的侷限性相比,DB2不BLU加速。你的情況是,你只能針對列組織表運行CS隔離級別的查詢。

要麼將​​連接配置更改爲使用CS隔離級別,要麼在創建表格的同時明確指定ORGANIZE BY ROW

+0

感謝mustaccio,你的解釋拯救了我的一天! –

相關問題