PreparedStatement を使用して、テーブルのフィールドにインデックスを作成する必要があります。私が実行しなければならないクエリは次のとおりです。
ALTER TABLE esa_matrix ADD INDEX doc_index (id_doc)
PreparedStatement
そのため、クエリの同じテキストでインスタンスを作成し、それに対してexecuteUpdate()
メソッドを実行しました。しかし、実行時に SQL 構文エラーが発生します。これはPreparedStatement
インスタンスの作成です:
PreparedStatement ps = conn.prepareStatement("ALTER TABLE "+ESATable+ "ADD INDEX doc_index ("+idDocLabel+")");
ps.executeUpdate();
ps.close();
私が得るこのSQLException:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'doc_index (id_doc)' at line 1
どうすればこれを解決できますか?
前もって感謝します、
アントニオ