gpt4 book ai didi

java - 我在提交详细信息时遇到以下错误 ORA-01745 : invalid host/bind variable name

转载 作者:行者123 更新时间:2023-12-02 03:13:04 25 4
gpt4 key购买 nike

保存方法

public static int save(Emp2 e){
int status=0;
try{
Connection con=EmpDb.getConnection();
PreparedStatement ps=con.prepareStatement("insert into empsoft(name,dob,bplace,age,bgroup,hw,disability,gender,email,mobile,mstatus,hobbies,nationality,religion,ug,specialization,grade,university,year,ug1,specialization1,grade1,university1,year1,ug2,specialization2,grade2,university2,year2,ug3,specialization3,grade3,university3,year3,post,dep,company,city,days,post1,dep1,company1,city1,days1,post2,dep2,company2,city2,days2,preaddress,peraddress,lno,pno) values (?,?,?,?,??,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
ps.setString(1,e.getEname());
ps.setString(2,e.getDob());
ps.setString(3, e.getBplace());
ps.setInt(4, e.getAge());
ps.setString(5, e.getBgroup());
ps.setString(6, e.getHw());
ps.setString(7, e.getDisability());
ps.setString(8, e.getGender());
ps.setString(9,e.getEmail());
ps.setString(10, e.getMobileno());
ps.setString(11, e.getMstatus());
ps.setString(12, e.getHobbies());
ps.setString(13, e.getNationality());
ps.setString(14, e.getReligion());
ps.setString(15, e.getUg());
ps.setString(16, e.getSpecialization());
ps.setString(17, e.getGrade());
ps.setString(18, e.getUniversity());
ps.setString(19, e.getYear());
ps.setString(20, e.getUg1());
ps.setString(21, e.getSpecialization1());
ps.setString(22, e.getGrade1());
ps.setString(23, e.getUniversity1());
ps.setString(24, e.getYear1());
ps.setString(25, e.getUg2());
ps.setString(26, e.getSpecialization());
ps.setString(27, e.getGrade2());
ps.setString(28, e.getUniversity2());
ps.setString(29, e.getYear2());
ps.setString(30, e.getUg3());
ps.setString(31, e.getSpecialization3());
ps.setString(32, e.getGrade3());
ps.setString(33, e.getUniversity3());
ps.setString(34, e.getYear3());
ps.setString(35, e.getPost());
ps.setString(36, e.getDep());
ps.setString(37, e.getCompany());
ps.setString(38, e.getCity());
ps.setString(39, e.getDays());
ps.setString(40, e.getPost1());
ps.setString(41, e.getDep1());
ps.setString(42, e.getCompany1());
ps.setString(43, e.getCity1());
ps.setString(44, e.getDays1());
ps.setString(45, e.getPost2());
ps.setString(46, e.getDep2());
ps.setString(47, e.getCompany2());
ps.setString(48, e.getCity2());
ps.setString(49, e.getDays2());
ps.setString(50, e.getPreaddress());
ps.setString(51, e.getPeraddress());
ps.setString(52, e.getLno());
ps.setString(53, e.getPno());
status=ps.executeUpdate();
con.close();
}
catch(Exception ex)
{
ex.printStackTrace();
}

return status;
}

保存 Servlet

protected void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException 
{
res.setContentType("text/html");
PrintWriter out=res.getWriter();
String ename=req.getParameter("ename");
String dob=req.getParameter("dob");
String bplace=req.getParameter("bplace");
String ag=req.getParameter("age");
int age=Integer.parseInt(ag);
String bgroup=req.getParameter("bgroup");
String hw=req.getParameter("hw");
String disability=req.getParameter("disability");
String gender=req.getParameter("gender");
String email=req.getParameter("email");
String mobileno=req.getParameter("mobileno");
String mstatus=req.getParameter("mstatus");
String hobbies=req.getParameter("hobbies");
String nationality=req.getParameter("nationality");
String religion=req.getParameter("religion");
String ug=req.getParameter("ug");
String specialization=req.getParameter("specialization");
String grade=req.getParameter("grade");
String university=req.getParameter("university");
String year=req.getParameter("year");
String ug1=req.getParameter("ug1");
String specialization1=req.getParameter("specialization1");
String grade1=req.getParameter("grade1");
String university1=req.getParameter("university1");
String year1=req.getParameter("year1");
String ug2=req.getParameter("ug2");
String specialization2=req.getParameter("specialization2");
String grade2=req.getParameter("grade2");
String university2=req.getParameter("university2");
String year2=req.getParameter("year2");
String ug3=req.getParameter("ug3");
String specialization3=req.getParameter("specialization3");
String grade3=req.getParameter("grade3");
String university3=req.getParameter("university3");
String year3=req.getParameter("year3");
String post=req.getParameter("post");
String dep=req.getParameter("dep");
String company=req.getParameter("company");
String city=req.getParameter("city");
String days=req.getParameter("days");
String post1=req.getParameter("post1");
String dep1=req.getParameter("dep1");
String company1=req.getParameter("company1");
String city1=req.getParameter("city1");
String days1=req.getParameter("days1");
String post2=req.getParameter("post2");
String dep2=req.getParameter("dep2");
String company2=req.getParameter("company2");
String city2=req.getParameter("city2");
String days2=req.getParameter("days2");
String preaddress=req.getParameter("preaddress");
String peraddress=req.getParameter("peraddress");
String lno=req.getParameter("lno");
String pno=req.getParameter("pno");

Emp2 e=new Emp2();
e.setEname(ename);
e.setDob(dob);
e.setBplace(bplace);
e.setAge(age);
e.setBgroup(bgroup);
e.setHw(hw);
e.setDisability(disability);
e.setGender(gender);
e.setEmail(email);
e.setMobileno(mobileno);
e.setMstatus(mstatus);
e.setHobbies(hobbies);
e.setNationality(nationality);
e.setReligion(religion);
e.setUg(ug);
e.setSpecialization(specialization);
e.setGrade(grade);
e.setUniversity(university);
e.setYear(year);
e.setUg1(ug1);
e.setSpecialization(specialization1);
e.setGrade1(grade1);
e.setUniversity(university1);
e.setYear1(year1);
e.setUg2(ug2);
e.setSpecialization2(specialization2);
e.setGrade2(grade2);
e.setUniversity2(university2);
e.setYear2(year2);
e.setUg3(ug3);
e.setSpecialization3(specialization3);
e.setGrade3(grade3);
e.setUniversity3(university3);
e.setYear3(year3);
e.setPost(post);
e.setDep(dep);
e.setCompany(company);
e.setCity(city);
e.setDays(days);
e.setPost1(post1);
e.setDep1(dep1);
e.setCompany1(company1);
e.setCity1(city1);
e.setDays1(days1);
e.setPost2(post2);
e.setDep2(dep2);
e.setCompany2(company2);
e.setCity2(city2);
e.setDays2(days2);
e.setPreaddress(preaddress);
e.setPeraddress(peraddress);
e.setLno(lno);
e.setPno(pno);
int status=EmpDb.save(e);
if(status>0){
out.print("<p>Record saved successfully!</p>");
req.getRequestDispatcher("EmpRegis.html").include(req, res);
}else{
out.println("Sorry! unable to save record");
}

out.close();
}

数据库

CREATE TABLE  "EMPSOFT" 
( "ID" NUMBER,
"ENAME" VARCHAR2(40) NOT NULL ENABLE,
"DOB" DATE NOT NULL ENABLE,
"BPLACE" VARCHAR2(40) NOT NULL ENABLE,
"AGE" NUMBER NOT NULL ENABLE,
"BGROUP" VARCHAR2(40) NOT NULL ENABLE,
"HW" VARCHAR2(400) NOT NULL ENABLE,
"DISABILITY" VARCHAR2(40) NOT NULL ENABLE,
"GENDER" VARCHAR2(40) NOT NULL ENABLE,
"EMAIL" VARCHAR2(40) NOT NULL ENABLE,
"MOBILENO" VARCHAR2(40) NOT NULL ENABLE,
"MSTATUS" VARCHAR2(40) NOT NULL ENABLE,
"HOBBIES" VARCHAR2(400) NOT NULL ENABLE,
"NATIONALITY" VARCHAR2(40) NOT NULL ENABLE,
"RELIGION" VARCHAR2(40) NOT NULL ENABLE,
"UG" VARCHAR2(40) NOT NULL ENABLE,
"SPECIALIZATION" VARCHAR2(40) NOT NULL ENABLE,
"GRADE" VARCHAR2(40) NOT NULL ENABLE,
"UNIVERSITY" VARCHAR2(400) NOT NULL ENABLE,
"YEAR" DATE NOT NULL ENABLE,
"UG1" VARCHAR2(40) NOT NULL ENABLE,
"SPECIALIZATION1" VARCHAR2(40) NOT NULL ENABLE,
"GRADE1" VARCHAR2(40) NOT NULL ENABLE,
"UNIVERSITY1" VARCHAR2(40) NOT NULL ENABLE,
"YEAR1" DATE NOT NULL ENABLE,
"UG2" VARCHAR2(40) NOT NULL ENABLE,
"SPECIALIZATION2" VARCHAR2(40) NOT NULL ENABLE,
"GRADE2" VARCHAR2(40) NOT NULL ENABLE,
"UNIVERSITY2" VARCHAR2(40) NOT NULL ENABLE,
"YEAR2" DATE NOT NULL ENABLE,
"UG3" VARCHAR2(40),
"SPECIALIZATION3" VARCHAR2(40),
"GRADE3" VARCHAR2(40),
"UNIVERSITY3" VARCHAR2(40),
"YEAR3" DATE,
"POST" VARCHAR2(40),
"DEP" VARCHAR2(40),
"COMPANY" VARCHAR2(40),
"CITY" VARCHAR2(40),
"DAYS" VARCHAR2(40),
"POST1" VARCHAR2(40),
"DEP1" VARCHAR2(40),
"COMPANY1" VARCHAR2(40),
"CITY1" VARCHAR2(40),
"DAYS1" VARCHAR2(40),
"POST2" VARCHAR2(40),
"DEP2" VARCHAR2(40),
"COMPANY2" VARCHAR2(40),
"CITY2" VARCHAR2(400),
"DAYS2" VARCHAR2(40),
"PREADDRESS" VARCHAR2(400) NOT NULL ENABLE,
"PERADDRESS" VARCHAR2(400) NOT NULL ENABLE,
"LNO" VARCHAR2(40) NOT NULL ENABLE,
"PNO" VARCHAR2(40) NOT NULL ENABLE,
CONSTRAINT "EMPSOFT_PK" PRIMARY KEY ("ID") ENABLE
)

最佳答案

缺少一个逗号:

PreparedStatement ps= ... values (?,?,?,?,??,?,?,...
^

您应该考虑标准化您的数据模型。至少我可以看到 table 上的人、教育背景和地址。

关于java - 我在提交详细信息时遇到以下错误 ORA-01745 : invalid host/bind variable name,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40750543/

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