当我尝试将数据插入oracle 11g数据库时,我在标题中收到错误。这是表格细节和我使用的功能:
private static void insertDetails() throws Exception{
Scanner sc=new Scanner(System.in);
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","AJ204","pract");
System.out.println("Connected database successfully...");
PreparedStatement ps=null;
ps=con.prepareStatement("INSERT INTO `STUDENT_PERS_DETAILS`(ENROLL_NO,NAME,GENDER,PERMANENT_ADDRESS_HOUSE_NO.,PERMANENT_ADDRESS_STREET_NAME,PERM._ADDR._NEAREST_LANDMARK,PERM._ADDR._PINCODE,CONTACT_NO.,EMAIL_ADDRESS,AADHAR) VALUE (?,?,?,?,?,?,?,?,?,?)");
System.out.println("Enter the student's details");
System.out.println("Enroll_No:");
long enroll_no=sc.nextLong();
ps.setLong(1, enroll_no);
System.out.println("Name:");
sc.nextLine();
String name2=sc.nextLine();
ps.setString(2, name2);
System.out.println("Gender:");
String gndr=sc.nextLine();
ps.setString(3, gndr);
System.out.println("Permanent Address details:");
System.out.println("\tHouse No.:");
String house_no=sc.nextLine();
ps.setString(4, house_no);
System.out.println("\tStreet Name:");
String street=sc.nextLine();
ps.setString(5, street);
System.out.println("\tNearest Landmark:");
String landmark=sc.nextLine();
ps.setString(6,landmark);
System.out.println("\tPincode:");
long pincode=sc.nextLong();
ps.setLong(7, pincode);
System.out.println("Contact No.:");
long cntct_no=sc.nextLong();
ps.setLong(8, cntct_no);
System.out.println("Email:");
String email=sc.nextLine();
ps.setString(9,email);
System.out.println("Aadhaar No.:");
long aadhaar_no=sc.nextLong();
ps.setLong(10, aadhaar_no);
System.out.println("Set success");
int n=ps.executeUpdate();
System.out.println("Updated");
ps.close();
con.close();
}
答案 0 :(得分:3)
您的SQL语句证明了这一点:
INSERT INTO `STUDENT_PERS_DETAILS` (
ENROLL_NO,
NAME,
GENDER,
PERMANENT_ADDRESS_HOUSE_NO.,
PERMANENT_ADDRESS_STREET_NAME,
PERM._ADDR._NEAREST_LANDMARK,
PERM._ADDR._PINCODE,
CONTACT_NO.,
EMAIL_ADDRESS,
AADHAR)
VALUE
(?,?,?,?,?,?,?,?,?,?)
它有几个错误:
.
(除非双引号,但这没用)VALUE
必须为VALUES