私はhibernate prepared statementを使って新しいテーブルを作成しようとしています。 "setparameter("values", value)"
のように、クエリに引用符を追加しているようです。 マイコード:Hibernate setParameterは文字列に一重引用符を追加します
String hql = "create table :values " + "(name VARCHAR(50))";
Query my = session.createSQLQuery(hql);
my.setParameter("values", value);
my.executeUpdate();
session.close();
エラー:
SEVERE: Servlet.service() for servlet [contextServlet] in context with path [/SpringSafeHouseService2.0] threw exception [Request processing failed; nested exception is org.hibernate.exception.SQLGrammarException: could not execute statement] with root cause
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 ''merkurijuss' (name VARCHAR(50))' at line 1
あなたは、どのようにSQLインジェクションからこのクエリを防ぐために準備されたステートメント – Jens