当前位置: 技术问答>java相关
高分送上,用jsp连接sqlserver,将数据插入到数据库,出现java.lang.ArrayIndexOutOfBoundsException异常
来源: 互联网 发布时间:2017-03-27
本文导语: 用jsp连接sqlserver,将数据插入到数据库的reservation表里,但结果没有插入成功,出现java.lang.ArrayIndexOutOfBoundsException异常 add.jsp文件的主要功能就是将输入的数据插入到数据库的reservation表里 add.jsp文件内容如下: ...
用jsp连接sqlserver,将数据插入到数据库的reservation表里,但结果没有插入成功,出现java.lang.ArrayIndexOutOfBoundsException异常
add.jsp文件的主要功能就是将输入的数据插入到数据库的reservation表里
add.jsp文件内容如下:
add books
reservation表的sql语句如下:
/*表reservation用于存储客人姓名、地址、城市、州、联系电话、邮编、dCheckInDate入住日期、
CheckOutDate结账(离开)日期、客人所住的房号iRoomNo、mServiceCharge各项服务费用(如Bars and Restaurants酒吧和餐饮)
、mRoomCharge房价 mTotalCharge总的费用(各类服务费用+房价)*/
create table reservation
(iCustomerID int identity(1,1) constraint pkcustomerID primary key,vCustomerName varchar(40),
vAddress varchar(50),vCity varchar(40),cState char(6),cPhone char(20),cZip char(10),
dCheckInDate datetime default(getdate()),dCheckOutDate datetime default(getdate()),iRoomNo int
constraint fkroomNo foreign key(iRoomNo) references room(iRoomNo),
mServiceCharge money constraint defservicecharge default(0),mRoomCharge money,
mTotalCharge money constraint deftotalcharge default(0))
add.jsp文件的主要功能就是将输入的数据插入到数据库的reservation表里
add.jsp文件内容如下:
add books
reservation表的sql语句如下:
/*表reservation用于存储客人姓名、地址、城市、州、联系电话、邮编、dCheckInDate入住日期、
CheckOutDate结账(离开)日期、客人所住的房号iRoomNo、mServiceCharge各项服务费用(如Bars and Restaurants酒吧和餐饮)
、mRoomCharge房价 mTotalCharge总的费用(各类服务费用+房价)*/
create table reservation
(iCustomerID int identity(1,1) constraint pkcustomerID primary key,vCustomerName varchar(40),
vAddress varchar(50),vCity varchar(40),cState char(6),cPhone char(20),cZip char(10),
dCheckInDate datetime default(getdate()),dCheckOutDate datetime default(getdate()),iRoomNo int
constraint fkroomNo foreign key(iRoomNo) references room(iRoomNo),
mServiceCharge money constraint defservicecharge default(0),mRoomCharge money,
mTotalCharge money constraint deftotalcharge default(0))
|
是数组下标越界了
将
insertreserv.setString(2,customername);
insertreserv.setString(3,address);
insertreserv.setString(4,city);
insertreserv.setString(5,state);
insertreserv.setString(6,phone);
insertreserv.setString(7,zip);
insertreserv.setInt(10,roomNo);
insertreserv.setFloat(12,roomcharge);
改成
insertreserv.setString(1,customername);
insertreserv.setString(2,address);
insertreserv.setString(3,city);
insertreserv.setString(4,state);
insertreserv.setString(5,phone);
insertreserv.setString(6,zip);
insertreserv.setInt(7,roomNo);
insertreserv.setFloat(8,roomcharge);
将
insertreserv.setString(2,customername);
insertreserv.setString(3,address);
insertreserv.setString(4,city);
insertreserv.setString(5,state);
insertreserv.setString(6,phone);
insertreserv.setString(7,zip);
insertreserv.setInt(10,roomNo);
insertreserv.setFloat(12,roomcharge);
改成
insertreserv.setString(1,customername);
insertreserv.setString(2,address);
insertreserv.setString(3,city);
insertreserv.setString(4,state);
insertreserv.setString(5,phone);
insertreserv.setString(6,zip);
insertreserv.setInt(7,roomNo);
insertreserv.setFloat(8,roomcharge);