这是我收到的消息 com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:您的SQL语法中有错误;检查与您的MySQL服务器版本相对应的手册,以便在#complemc_Id =' 1''''''''''在第1行
Class.forName("com.mysql.jdbc.Driver");
Connection conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/optimalcms","root","123456");
Statement st=conn.createStatement();
PreparedStatement pst;
Object item = RenterRevealeds_ComplexName_ComboBox.getSelectedItem();
int value = ((Item)item).getId();
String sql="Select complex.cox_name as 'أسم المجمع',complex.cox_bld_num as 'رقم المجمع',client.clnt_name as 'أسم المسأجر',client.clnt_phone_number as 'رقم هاتف المستأجر',office.ofc_num as 'رقم المكتب',status.status_ofc_status as 'حالةالمكتب'"
+ "from client"
+ "INNER JOIN office ON office.ofc_Id = client.clnt_ofc_Id "
+ "INNER JOIN complex ON complex.cox_Id = client.clnt_cox_Id"
+ "INNER JOIN status ON status.status_Id = office.ofc_status_Id"
+ "WHERE complex.cox_Id='"+value+"'";
pst= conn.prepareStatement(sql);
ResultSet rs;
rs=pst.executeQuery();
jTable1.setModel(DbUtils.resultSetToTableModel(rs));
conn.close();
答案 0 :(得分:0)
不要忘记在单词之间添加空格:
"INNER JOIN complex ON complex.cox_Id = client.clnt_cox_Id"
应该有一个尾随空格,例如:
"INNER JOIN complex ON complex.cox_Id = client.clnt_cox_Id "
还有下一行(以及第一行和第二行)。