java - SQL view creation with prepared statements -


i having trouble generating views based on code follows:

final string[] clusterclasses = {"exponential", "linear", "periodic"}; java.sql.preparedstatement pcreateviewstmt = conn.preparestatement(     "create view ?_? "     + "select * golden_table clust_list ? ?");  for(int = 0; < 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]+"%");     } } 

i sql syntax exception:

exception in thread "main" com.mysql.jdbc.exceptions.jdbc4.mysqlsyntaxerrorexception:  have error in sql syntax; check manual corresponds  mysql server version right syntax use near ''exponential'_'periodic'  select * golden_table clust_list '%e' @ line 1 

this has preparedstatement , wildcards ? can't quite figure out though.

here 1 iteration of i loop produce create view command:

create view exponential_periodic  select *    golden_table   clust_list '%exponential%periodic%'; 


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -