2017-04-12 61 views
0

Error: java.sql.SQLSyntaxErrorException: 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 'dc, customerdata cd WHERE dc.location = '2' AND cd.username = 'jasmin" at line 1java.sql.SQLSyntaxErrorException:您的SQL語法有錯誤;

String dressLoc = dressno; 
    String nameRenter = jLabel1.getText(); 

    String sql = "INSERT INTO orderdata (dressname,price,currentrenter,stat" 
      + ",datereserve) SELECT dressname, price, concat(concat(fname," 
      + "' '), lname)AS currentrenter, 'Reserve', CURRENT_TIMESTAMP" 
      + "FROM dresscatalog dc, customerdata cd WHERE dc.location = ? " 
      + "AND cd.username = ?"; 
    try 
    { 
     pst=conn.prepareStatement(sql); 
     pst.setString(1,dressLoc); 
     pst.setString(2,nameRenter); 
     pst.executeUpdate(); 


    } 
    catch(SQLException ex) 
    { 
     JOptionPane.showMessageDialog(this, ex); 
    } 

回答

0

你錯過了一個空白CURRENT_TIMESTAMPFROM

+ "' '), lname)AS currentrenter, 'Reserve', CURRENT_TIMESTAMP " 
     + "FROM dresscatalog 

之間,我想你錯過了連接條件。在當下你得到一個carthesian產品

+0

非常感謝你! –

+0

@JasminApolinar歡迎您 – Jens

相關問題