gpt4 book ai didi

java - 为什么我不断收到这个该死的 SQL*Plus 无效标识符错误?

转载 作者:行者123 更新时间:2023-11-29 09:46:01 28 4
gpt4 key购买 nike

当我尝试运行以下脚本时,我不断收到无效标识符异常: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();

最佳答案

你可以试试

<%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 ) ;%>

希望对您有所帮助。

关于java - 为什么我不断收到这个该死的 SQL*Plus 无效标识符错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5696296/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com