任何人都可以告诉我为什么我得到SQL * PLUS无效标识符错误?

时间:2011-04-17 14:01:52

标签: java jdbc sqlplus

为什么我一直收到此错误:

javax.servlet.ServletException:java.sql.SQLException:[Oracle] [ODBC] [Ora] ORA-00904:“PURCHASE_PRICE”:标识符无效

正如您所见,purchase_Price显然是一个有效的标识符。

      //get parameters from the request
   String homeID=request.getParameter("home_ID");
   String modelID=request.getParameter("model_ID");
   String lotSize=request.getParameter("lot_Size");
   String location=request.getParameter("location");
   String purchasePrice=request.getParameter("purchase_Price");
   String streetName=request.getParameter("street_Name");
   String city=request.getParameter("city");
   String state=request.getParameter("state");
   String zipCode=request.getParameter("zip_Code"); 


  preparedStatement = conn.prepareStatement("INSERT INTO customer (home_ID, model_ID, lot_Size, location, purchase_Price    , street_Name, city, state, zip_Code)"
                + " VALUES (?,?,?,?,?,?,?,?,?)");

   preparedStatement.setInt(1,Integer.valueOf(homeID));
   preparedStatement.setInt(2,Integer.valueOf(modelID));
   preparedStatement.setString(3,lotSize);
   preparedStatement.setString(4,location);
   preparedStatement.setInt(5,Integer.valueOf(purchasePrice));
   preparedStatement.setString(6,streetName);
   preparedStatement.setString(7,city);
   preparedStatement.setString(8,state);
   preparedStatement.setString(9,zipCode);
   preparedStatement.executeUpdate();

SQL CODE

   CREATE TABLE home
    (home_ID        NUMBER          NOT NULL,
    model_ID        NUMBER          NOT NULL,
    lot_Size        VARCHAR2(50)        ,
    location        VARCHAR2(50)        ,
    purchase_Price      NUMBER          ,
    street_Name     VARCHAR2(50)        NoT NULL,
    city            VARCHAR2(30)        NOT NULL,
    state           VARCHAR2(50)        NOT NULL,
    zip_Code        VARCHAR(5)      NOT NULL
    );

1 个答案:

答案 0 :(得分:2)

也许是因为你在SQL中向我们展示了一个表home,但是用JDBC插入customer