我有一个新数据库。我想插入手动值并从数据库中选择表名。但它显示一个错误。我使用以下代码。我的行值是第一个是 aString
并且以下是整数(这里=fcltyname 是唯一的String
)
connection = (Connection) dbSource.getConnection();
String qry = "SELECT studentName From batcha ";
System.out.println(fcltyName);
stmt = (PreparedStatement) connection.prepareStatement(qry);
rs = stmt.executeQuery();
while (rs.next()) {
String check=new String(rs.getString(("studentName")));
String student = check.replaceAll("\\s","");
Class.forName("com.mysql.jdbc.Driver");
connection = (Connection) DriverManager.getConnection(DB_URL_table, USER, PASS);
String sql1 = "INSERT IGNORE INTO "+student+" (fcltyName,CommunicationOral,Communicationwritten,Leadership,AnalyticalAbilities,Interpersonalskills,DecisionMakingSkills,SelfConfidence,Creativity,Punctualityregularity,GeneralAwareness,Commitment,HardWork)VALUES("+fcltyName+",0,0,0,0,0,0,0,0,0,0,0,0)";
newStmt=(PreparedStatement) connection.prepareStatement(sql1);
newStmt.executeUpdate(sql1);
newStmt.close();
错误
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 '0,0,0,0,0,0,0,0,0,0,0,0)' at line 1