1

以下のスクリプトを実行しようとすると、無効な識別子例外が発生し続けます: javax.servlet.ServletException: java.sql.SQLException: [Oracle][ODBC][Ora]ORA-00904: "CUSTID": 無効な識別子

   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); 
   conn = DriverManager.getConnection("jdbc:odbc:rreOracle","xxxxxx","xxxxxxxx"); 
   stmt = conn.createStatement(); 
  PreparedStatement preparedStatement;

      //get parameters from the request
      String custID=request.getParameter("cust_ID");
      String saleID=request.getParameter("sale_ID");
      String firstName=request.getParameter("first_Name");
      String mInitial=request.getParameter("mI");
      String lastName=request.getParameter("last_Name");
      String streetName=request.getParameter("street");
      String city=request.getParameter("city");
      String state=request.getParameter("state");
      String zipCode=request.getParameter("zip_Code");
      String DOB=request.getParameter("DOB");
      String agentID=request.getParameter("agent_ID");
      String homePhone=request.getParameter("home_Phone");
      String cellPhone=request.getParameter("cell_Phone");
      String profession=request.getParameter("profession");
      String employer=request.getParameter("employer");
      String referrer=request.getParameter("referrer");


   preparedStatement = conn.prepareStatement("UPDATE customer"
+ " SET customer.cust_ID=?, customer.sale_ID=?, customer.first_Name=?, customer.mI=?, customer.last_Name=?, customer.street_Name=?, customer.city=?, customer.state=?, customer.zip_Code=?,customer. DOB=?, customer.agent_ID=?, customer.home_Phone=?, customer.cell_Phone=?, customer.profession=?, customer.employer=?, customer.referrer=?"
+ " WHERE customer.cust_ID=custID ") ;

   preparedStatement.setInt(1, Integer.valueOf(custID));
   preparedStatement.setInt(2, Integer.valueOf(saleID));
   preparedStatement.setString(3, firstName);
   preparedStatement.setString(4, mInitial);
   preparedStatement.setString(5, lastName);
   preparedStatement.setString(6, streetName);
   preparedStatement.setString(7, city);
   preparedStatement.setString(8, state);
   preparedStatement.setString(9, zipCode);
   preparedStatement.setString(10, DOB);
   preparedStatement.setInt(11, Integer.valueOf(agentID));
   preparedStatement.setString(12, homePhone);
   preparedStatement.setString(13, cellPhone);
   preparedStatement.setString(14, profession);
   preparedStatement.setString(15, employer);
   preparedStatement.setString(16, referrer);

   preparedStatement.executeUpdate();
4

2 に答える 2

9

あなたが試すことができます

<%preparedStatement = conn.prepareStatement("UPDATE customer"
+ " SET customer.cust_ID=?, customer.sale_ID=?, customer.first_Name=?, customer.mI=?, customer.last_Name=?, customer.street_Name=?, customer.city=?, customer.state=?, customer.zip_Code=?,customer. DOB=?, customer.agent_ID=?, customer.home_Phone=?, customer.cell_Phone=?, customer.profession=?, customer.employer=?, customer.referrer=?"
+ " WHERE customer.cust_ID=?") ;%>
<%preparedStatement.setString(17, custID );%>

また

<%preparedStatement = conn.prepareStatement("UPDATE customer"
+ " SET customer.cust_ID=?, customer.sale_ID=?, customer.first_Name=?, customer.mI=?, customer.last_Name=?, customer.street_Name=?, customer.city=?, customer.state=?, customer.zip_Code=?,customer. DOB=?, customer.agent_ID=?, customer.home_Phone=?, customer.cell_Phone=?, customer.profession=?, customer.employer=?, customer.referrer=?"
+ " WHERE customer.cust_ID="+custID ) ;%>

それが役に立てば幸い。

于 2011-04-17T21:43:46.520 に答える
3

ステートメント「WHERE customer.cust_ID=custID」のこの部分で、オラクルは「custID」という値を探しています。

その時点で、コンテキスト内の変数名は関係ありません-SQL内で「where A = B」ステートメントは「列A ==列B」を参照しています-テーブルに「custID」列がないため、オラクルは不平を言います.

于 2011-04-17T20:50:13.813 に答える