我无法根据我的代码生成视图,如下所示:
final String[] clusterClasses = {"exponential", "linear", "periodic"};
java.sql.PreparedStatement pCreateViewStmt = conn.prepareStatement(
"create view ?_? as "
+ "select * from golden_table where clust_list like ? ?");
for(int i = 0; i < clusterClasses.length; i++) {
for(int j = 0; j < clusterClasses.length; j++) {
pCreateViewStmt.setString(1, clusterClasses[i]);
pCreateViewStmt.setString(2, clusterClasses[j]);
pCreateViewStmt.setString(3, "%"+clusterClasses[i]);
pCreateViewStmt.setString(4, "%"+clusterClasses[j]+"%");
}
}
我得到一个SQL语法异常:
Exception in thread "main" 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 ''exponential'_'periodic'
as select * from golden_table where clust_list like '%e' at line 1
这与PreparedStatement和通配符?
有关但我无法弄明白。
以下是i
循环的一次迭代可以作为创建视图命令生成的内容:
create view exponential_periodic AS
select *
from golden_table
where clust_list like '%exponential%periodic%';