📄 hotelconfirm.jsp
字号:
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.sql.*"%>
<%@ page import="BeanLink.DBBean"%>
<jsp:useBean id="db" class="BeanLink.DBBean" scope="page"/>
<%
Connection con=null;
Statement stmt=null;
ResultSet rs=null;
String driver="sun.jdbc.odbc.JdbcOdbcDriver"; //驱动程序
String url="jdbc:odbc:airline"; //数据源的url
String user1=""; //连接数据库的用户名
String pass1=""; //连接数据库的口令
String strSQL2; //要执行的sql语句
String strSQL3; //要执行的sql语句
String cityName=request.getParameter("cityName");
String hotelName=request.getParameter("hotelName");
String fuwujibie=request.getParameter("fuwujibie");
String p_dan=request.getParameter("p_dan");
String p_danP=request.getParameter("p_danP");
String p_shuang=request.getParameter("p_shuang");
String p_shuangP=request.getParameter("p_shuangP");
String p_tao=request.getParameter("p_tao");
String p_taoP=request.getParameter("p_taoP");
String h_dan=request.getParameter("h_dan");
String h_danP=request.getParameter("h_danP");
String h_shuang=request.getParameter("h_shuang");
String h_shuangP=request.getParameter("h_shuangP");
String h_tao=request.getParameter("h_tao");
String h_taoP=request.getParameter("h_taoP");
String zongtong_tao=request.getParameter("zongtong_tao");
String zongtong_taoP=request.getParameter("zongtong_taoP");
String fuyan=request.getParameter("fuyan");
hotelName=new String(hotelName.getBytes("8859_1"));
fuwujibie=new String(fuwujibie.getBytes("8859_1"));
fuyan=new String(fuyan.getBytes("8859_1"));
if(!db.initialization(driver,url,user1,pass1)) //进行初始化
{
out.println(db.getHint());
}
else try{
strSQL3="select count(*) from airline_hotelxinxi with(READCOMMITTED) where hotelName='"+hotelName+"'";//判断是否有用户存在
strSQL2="insert into airline_hotelxinxi(cityFlg,";
strSQL2=strSQL2+"hotelName,fuwujibie,p_dan,p_danP,p_shuang,";
strSQL2=strSQL2+"p_shuangP,p_tao,p_taoP,h_dan,h_danP,h_shuang,";
strSQL2=strSQL2+"h_shuangP,h_tao,h_taoP,zongtong_tao,zongtong_taoP,fuyan)";
strSQL2=strSQL2+" values("+cityName;
strSQL2=strSQL2+" ,'"+hotelName+"'";
strSQL2=strSQL2+" ,'"+fuwujibie+"'";
strSQL2=strSQL2+","+p_dan;
strSQL2=strSQL2+" ,"+p_danP;
strSQL2=strSQL2+" ,"+p_shuang;
strSQL2=strSQL2+" ,"+p_shuangP;
strSQL2=strSQL2+" ,"+p_tao;
strSQL2=strSQL2+" ,"+p_taoP;
strSQL2=strSQL2+" ,"+h_dan;
strSQL2=strSQL2+" ,"+h_danP;
strSQL2=strSQL2+" ,"+h_shuang;
strSQL2=strSQL2+" ,"+h_shuangP;
strSQL2=strSQL2+" ,"+h_tao;
strSQL2=strSQL2+" ,"+h_taoP;
strSQL2=strSQL2+" ,"+zongtong_tao;
strSQL2=strSQL2+" ,"+zongtong_taoP;
strSQL2=strSQL2+" ,'"+fuyan+"')";
rs=db.executeQuery(strSQL3);
rs.next();
if(rs.getInt(1)==1)
{
out.print("<script language=JavaScript>");
out.print("alert('该酒店已经存在了,请添加其他酒店!');");
out.print("window.location.href ='view.jsp'");
out.print(" </script>" );
}
else
{
db.executeUpdate(strSQL2);
out.print("<script language=JavaScript>");
out.print("alert('新酒店增加成功!');");
out.print("window.location.href ='view.jsp'");
out.print(" </script>" );
}
}
catch(Exception e2){
out.println("数据库异常!");
out.println(e2.toString());
}
finally{
try{
if(rs!=null) rs.close();
if(stmt!=null) stmt.close();
if(con!=null) con.close();
}
catch(Exception e){}
}
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -