java.sql.SQLSyntaxErrorException:ORA-00936:缺少表达式错误

时间:2015-06-30 11:37:19

标签: oracle

我已经进行了数据库名称查询,其中包含了代码显示错误表达错误的详细信息。

 private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        // TODO add your handling code here:
        String d=jTextField1.getText();
         String e=jTextField2.getText();
          try
        {
            connect ob=new connect();
            Connection con=ob.conn();
            PreparedStatement pr=con.prepareStatement("select * from ENQUIRY where from=? and to=?");

            pr.setString(1,d);
            pr.setString(2,e);
            ResultSet rs=pr.executeQuery();
            boolean status=false;
            while(rs.next())
            {
                status=true;
            }
            if(status==true)
            {
                new NewJFrame13().setVisible(true);
            }
            else
            {
                    new NewJFrame5().setVisible(true);

            }

        super.dispose();
        }
        catch(Exception a)
        {
            System.out.println(a);      
        } 

1 个答案:

答案 0 :(得分:0)

使用from / to的列名可能不是一个好主意,因为这些是oracle中的保留字。您需要将查询更改为:

select * from ENQUIRY where "from"=? and "to"=?
相关问题