package wanggsx.ejb;
import wanggsx.ejb.*;
import java.util.*;
import java.sql.* ;
import javax.sql.*;
import javax.naming.*;
import java.lang.*;
/**
* Bean implementation class for Enterprise Bean: Hotel
*/
public class hotelBean implements javax.ejb.SessionBean
{
private javax.ejb.SessionContext mySessionCtx;
/**
* getSessionContext
*/
public javax.ejb.SessionContext getSessionContext()
{
return mySessionCtx;
}
/**
* setSessionContext
*/
public void setSessionContext(javax.ejb.SessionContext ctx)
{
mySessionCtx = ctx;
}
/**
* ejbActivate
*/
public void ejbActivate()
{}
/**
* ejbCreate
*/
public void ejbCreate() throws javax.ejb.CreateException
{}
/**
* ejbPassivate
*/
public void ejbPassivate()
{}
/**
* ejbRemove
*/
public void ejbRemove()
{}
/**
* 商务方法
*/
Context ctx;
/**
* 属性,表示数据源
*/
DataSource ds;
/**
* 属性,statement
*/
Statement stmt;
/**
* 属性,PreparedStatement
*/
PreparedStatement pstmt;
/**
* 属性,查询结果
*/
ResultSet rs;
/**
*初始化数据源
*/
public void init(){
try{
/*Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
ds = (DataSource)envCtx.lookup("jdbc/mydatabase");*/
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
// ds = (DataSource)initCtx.lookup("java:/MSSQLDSLabour").
ds = (DataSource)initCtx.lookup("java:/database");
System.out.println("connect the database");
}
catch(Exception E){
System.out.println("Init DataSource Error: "+E);
}
}
public int UpdateBookUser()
{
Connection con = null;
String a="RemainToday";
String b="RemainTomorrow";
String c="RemainAfterTomorrow";
String d="RemainInThird";
int flag=0;
int flag1=0;
int flag2=0;
int flag3=0;
int flag4=0;
init();
try{
con = ds.getConnection();
pstmt = con.prepareStatement("delete from Hotel_Book_User where 预订日期=?");
pstmt.setString(1,a);
flag1 = pstmt.executeUpdate();
}//end try
catch (SQLException ex){
System.out.println("sql error: "+ex);
}
catch (Exception E){
System.out.println("Service Error: "+E);
}
finally{
if (rs!=null){
try { rs.close();} catch (Exception ignore){ };
}
if (pstmt!=null){
try { pstmt.close();} catch (Exception ignore){ };
}
if (con!=null){
try { con.close();} catch (Exception ignore){ };
}
}//finally
try{
con = ds.getConnection();
pstmt=con.prepareStatement("update Hotel_Book_User set 预订日期=? where 预订日期=?");
pstmt.setString(1,a);
pstmt.setString(2,b);
flag2 = pstmt.executeUpdate();
}//end try
catch (SQLException ex){
System.out.println("sql error: "+ex);
}
catch (Exception E){
System.out.println("Service Error: "+E);
}
finally{
if (rs!=null){
try { rs.close();} catch (Exception ignore){ };
}
if (pstmt!=null){
try { pstmt.close();} catch (Exception ignore){ };
}
if (con!=null){
try { con.close();} catch (Exception ignore){ };
}
}//finally
try{
con = ds.getConnection();
pstmt=con.prepareStatement("update Hotel_Book_User set 预订日期=? where 预订日期=?");
pstmt.setString(1,b);
pstmt.setString(2,c);
flag3 = pstmt.executeUpdate();
}//end try
catch (SQLException ex){
System.out.println("sql error: "+ex);
}
catch (Exception E){
System.out.println("Service Error: "+E);
}
finally{
if (rs!=null){
try { rs.close();} catch (Exception ignore){ };
}
if (pstmt!=null){
try { pstmt.close();} catch (Exception ignore){ };
}
if (con!=null){
try { con.close();} catch (Exception ignore){ };
}
}//finally
try{
con = ds.getConnection();
pstmt=con.prepareStatement("update Hotel_Book_User set 预订日期=? where 预订日期=?");
pstmt.setString(1,c);
pstmt.setString(2,d);
flag4 = pstmt.executeUpdate();
}//end try
catch (SQLException ex){
System.out.println("sql error: "+ex);
}
catch (Exception E){
System.out.println("Service Error: "+E);
}
finally{
if (rs!=null){
try { rs.close();} catch (Exception ignore){ };
}
if (pstmt!=null){
try { pstmt.close();} catch (Exception ignore){ };
}
if (con!=null){
try { con.close();} catch (Exception ignore){ };
}
}//finally
flag=flag1 + flag2 + flag3 + flag4;
return flag;
}
public Vector FHotelAdministor(){
Connection con = null;
Vector data = new Vector();
init();
try{
con = ds.getConnection();
//必须这样设置以对结果集进行指针操作
stmt = con.createStatement();
rs=stmt.executeQuery("select user_name,user_password,super_password,user_sex from Hotel_Administor");
System.out.println("enter the hotel_administor");
while (rs.next())
{
Hashtable ht = new Hashtable();
ht.put("a",rs.getString("user_name"));
ht.put("b",rs.getString("user_password"));
ht.put("c",rs.getString("super_password"));
ht.put("d",rs.getString("user_sex"));
data.addElement(ht);
}
}
catch(SQLException ex){
System.out.println("ex is "+ex);
}
catch (Exception E){
System.out.println("Service Error: "+E);
}
finally{
if (rs!=null){
try { rs.close();} catch (Exception ignore){ };
}
if (stmt!=null){
try { stmt.close();} catch (Exception ignore){ };
}
if (con!=null){
try { con.close();} catch (Exception ignore){ };
}
}//finally
return data;
}
public Vector FHotelRoom(){
Connection con = null;
Vector data = new Vector();
init();
try{
con = ds.getConnection();
//必须这样设置以对结果集进行指针操作
stmt = con.createStatement();
rs=stmt.executeQuery("select RoomID,RoomType,RoomPrice,IsEmpty,User_IdCard from Hotel_Room");
System.out.println("enter the hotel_room");
while (rs.next())
{
Hashtable ht = new Hashtable();
ht.put("a",rs.getString("RoomID"));
ht.put("b",rs.getString("RoomType"));
ht.put("c",rs.getString("RoomPrice"));
ht.put("d",rs.getString("IsEmpty"));
ht.put("e",rs.getString("User_IdCard"));
data.addElement(ht);
}
}
catch(SQLException ex){
System.out.println("ex is "+ex);
}
catch (Exception E){
System.out.println("Service Error: "+E);
}
finally{
if (rs!=null){
try { rs.close();} catch (Exception ignore){ };
}
if (stmt!=null){
try { stmt.close();} catch (Exception ignore){ };
}
if (con!=null){
try { con.close();} catch (Exception ignore){ };
}
}//finally
return data;
}
public Vector FHotelRoomEmpty(){
Connection con = null;
Vector data = new Vector();
init();
try{
con = ds.getConnection();
//必须这样设置以对结果集进行指针操作
stmt = con.createStatement();
rs=stmt.executeQuery("select RoomID,RoomType from Hotel_Room where IsEmpty='0'");
System.out.println("enter the hotel_room");
while (rs.next())
{
Hashtable ht = new Hashtable();
ht.put("a",rs.getString("RoomID"));
ht.put("b",rs.getString("RoomType"));
data.addElement(ht);
}
}
catch(SQLException ex){
System.out.println("ex is "+ex);
}
catch (Exception E){
System.out.println("Service Error: "+E);
}
finally{
if (rs!=null){
try { rs.close();} catch (Exception ignore){ };
}
if (stmt!=null){
try { stmt.close();} catch (Exception ignore){ };
}
if (con!=null){
try { con.close();} catch (Exception ignore){ };
}
}//finally
return data;
}
public Vector FHotelBookUser(){
Connection con = null;
Vector data = new Vector();
init();
try{
con = ds.getConnection();
//必须这样设置以对结果集进行指针操作
stmt = con.createStatement();
rs=stmt.executeQuery("select id,电子邮箱,手机号,预订房间数,预订房间类型,预订日期 from Hotel_Book_User");
System.out.println("enter the Hotel_Book_User");
while (rs.next())
{
Hashtable ht = new Hashtable();
ht.put("a",rs.getString("id"));
ht.put("b",rs.getString("电子邮箱"));
ht.put("c",rs.getString("手机号"));
ht.put("d",rs.getString("预订房间数"));
ht.put("e",rs.getString("预订房间类型"));
ht.put("f",rs.getString("预订日期"));
data.addElement(ht);
}
}
catch(SQLException ex){
System.out.println("ex is "+ex);
}
catch (Exception E){
System.out.println("Service Error: "+E);
}
finally{
if (rs!=null){
try { rs.close();} catch (Exception ignore){ };
}
if (stmt!=null){
try { stmt.close();} catch (Exception ignore){ };
}
if (con!=null){
try { con.close();} catch (Exception ignore){ };
}
}//finally
return data;
}
public Vector FHotelRoomInfo(){
Connection con = null;
Vector data = new Vector();
init();
try{
con = ds.getConnection();
//必须这样设置以对结果集进行指针操作
stmt = con.createStatement();
rs=stmt.executeQuery("select RoomType,RoomPrice,RemainToday,RemainTomorrow,RemainAfterTomorrow,RemainInThird,Announcement from Hotel_Room_Info");
System.out.println("enter the hotel_room_info");
while (rs.next())
{
Hashtable ht = new Hashtable();
ht.put("a",rs.getString("RoomType"));
ht.put("b",rs.getString("RoomPrice"));
ht.put("c",rs.getString("RemainToday"));
ht.put("d",rs.getString("RemainTomorrow"));
ht.put("e",rs.getString("RemainAfterTomorrow"));
ht.put("f",rs.getString("RemainInThird"));
ht.put("g",rs.getString("Announcement"));
data.addElement(ht);
}
}
catch(SQLException ex){
System.out.println("ex is "+ex);
}
catch (Exception E){
System.out.println("Service Error: "+E);
}
finally{
if (rs!=null){
try { rs.close();} catch (Exception ignore){ };
}
if (stmt!=null){
try { stmt.close();} catch (Exception ignore){ };
}
if (con!=null){
try { con.close();} catch (Exception ignore){ };
}
}//finally
return data;
}
public int ResetRoomRemain(){
Connection con = null;
Vector data= new Vector();
Hashtable ht1=null;
int i;
String t="";
int flag=0;
init();
try{
con = ds.getConnection();
//必须这样设置以对结果集进行指针操作
stmt = con.createStatement();
rs=stmt.executeQuery("select RoomTotal from Hotel_Room_Info");
while (rs.next())
{
pstmt = con.prepareStatement("update Hotel_Room_Info set RemainToday=?,RemainTomorrow=?,RemainAfterTomorrow=?,RemainInThird=? where RoomTotal=?");
pstmt.setString(1,rs.getString("RoomTotal"));
pstmt.setString(2,rs.getString("RoomTotal"));
pstmt.setString(3,rs.getString("RoomTotal"));
pstmt.setString(4,rs.getString("RoomTotal"));
pstmt.setString(5,rs.getString("RoomTotal"));
flag = pstmt.executeUpdate();
}
}
catch(SQLException ex){
System.out.println("ex is "+ex);
}
catch (Exception E){
System.out.println("Service Error: "+E);
}
finally{
if (rs!=null){
try { rs.close();} catch (Exception ignore){ };
}
if (stmt!=null){
try { stmt.close();} catch (Exception ignore){ };
}
if (con!=null){
try { con.close();} catch (Exception ignore){ };
}
}//finally
return flag;
}
public Vector FHotelRoomInfo2(){
Connection con = null;
Vector data = new Vector();
init();
try{
con = ds.getConnection();
//必须这样设置以对结果集进行指针操作
stmt = con.createStatement();
rs=stmt.executeQuery("select RoomType,RoomPrice,RoomTotal,RemainToday,RemainTomorrow,RemainAfterTomorrow,RemainInThird,Announcement from Hotel_Room_Info");
System.out.println("enter the hotel_room_info");
while (rs.next())
{
Hashtable ht = new Hashtable();
ht.put("a",rs.getString("RoomType"));
ht.put("b",rs.getString("RoomPrice"));
ht.put("c",rs.getString("RoomTotal"));
ht.put("d",rs.getString("RemainToday"));
ht.put("e",rs.getString("RemainTomorrow"));
ht.put("f",rs.getString("RemainAfterTomorrow"));
ht.put("g",rs.getString("RemainInThird"));
ht.put("h",rs.getString("Announcement"));
data.addElement(ht);
}
}
catch(SQLException ex){
System.out.println("ex is "+ex);
}
catch (Exception E){
System.out.println("Service Error: "+E);
}
finally{
if (rs!=null){
try { rs.close();} catch (Exception ignore){ };
}
if (stmt!=null){
try { stmt.close();} catch (Exception ignore){ };
}
if (con!=null){
try { con.close();} catch (Exception ignore){ };
}
}//finally
return data;
}
public Vector LHotelRoomNO(String bookdate,String roomtype){
Connection con = null;
Vector data = new Vector();
init();
try{
con = ds.getConnection();
//必须这样设置以对结果集进行指针操作
stmt = con.createStatement();
rs=stmt.executeQuery("select "+bookdate+" from Hotel_Room_Info where RoomType='"+roomtype+"'");
System.out.println("enter the hotel_room_info");
while (rs.next())
{
Hashtable ht = new Hashtable();
ht.put("a",rs.getString(""+bookdate+""));
data.addElement(ht);
}
}
catch(SQLException ex){
System.out.println("ex is "+ex);
}
catch (Exception E){
System.out.println("Service Error: "+E);
}
finally{
if (rs!=null){
try { rs.close();} catch (Exception ignore){ };
}
if (stmt!=null){
try { stmt.close();} catch (Exception ignore){ };
}
if (con!=null){
try { con.close();} catch (Exception ignore){ };
}
}//finally
return data;
}
public Vector LHotelRoomInfo(String roomtype){
Connection con = null;
Vector data = new Vector();
init();
try{
con = ds.getConnection();
//必须这样设置以对结果集进行指针操作
stmt = con.createStatement();
rs=stmt.executeQuery("select RoomType,RoomPrice,RoomTotal,RemainToday,RemainTomorrow,RemainAfterTomorrow,RemainInThird,Announcement from Hotel_Room_Info where RoomType='"+roomtype+"'");
System.out.println("enter the hotel_room_info");
while (rs.next())
{
Hashtable ht = new Hashtable();
ht.put("a",rs.getString("RoomType"));
ht.put("b",rs.getString("RoomPrice"));
ht.put("c",rs.getString("RoomTotal"));
ht.put("d",rs.getString("RemainToday"));
ht.put("e",rs.getString("RemainTomorrow"));
ht.put("f",rs.getString("RemainAfterTomorrow"));
ht.put("g",rs.getString("RemainInThird"));
ht.put("h",rs.getString("Announcement"));
data.addElement(ht);
}
}
catch(SQLException ex){
System.out.println("ex is "+ex);
}
catch (Exception E){
System.out.println("Service Error: "+E);
}
finally{
if (rs!=null){
try { rs.close();} catch (Exception ignore){ };
}
if (stmt!=null){
try { stmt.close();} catch (Exception ignore){ };
}
if (con!=null){
try { con.close();} catch (Exception ignore){ };
}
}//finally
return data;
}
public Vector LHotelRoom(String roomid){
Connection con = null;
Vector data = new Vector();
init();
try{
con = ds.getConnection();
//必须这样设置以对结果集进行指针操作
stmt = con.createStatement();
rs=stmt.executeQuery("select RoomID,RoomType,RoomPrice,IsEmpty,User_IdCard from Hotel_Room where RoomID='"+roomid+"'");
System.out.println("enter the hotel_room");
while (rs.next())
{
Hashtable ht = new Hashtable();
ht.put("a",rs.getString("RoomID"));
ht.put("b",rs.getString("RoomType"));
ht.put("c",rs.getString("RoomPrice"));
ht.put("d",rs.getString("IsEmpty"));
ht.put("e",rs.getString("User_IdCard"));
data.addElement(ht);
}
}
catch(SQLException ex){
System.out.println("ex is "+ex);
}
catch (Exception E){
System.out.println("Service Error: "+E);
}
finally{
if (rs!=null){
try { rs.close();} catch (Exception ignore){ };
}
if (stmt!=null){
try { stmt.close();} catch (Exception ignore){ };
}
if (con!=null){
try { con.close();} catch (Exception ignore){ };
}
}//finally
return data;
}
public Vector LHotelBookUser(String id){
Connection con = null;
Vector data = new Vector();
init();
try{
con = ds.getConnection();
//必须这样设置以对结果集进行指针操作
stmt = con.createStatement();
rs=stmt.executeQuery("select id,电子邮箱,手机号,预订房间数,预订房间类型,预订日期 from Hotel_Book_User where id='"+id+"'");
System.out.println("enter the Hotel_Book_User");
while (rs.next())
{
Hashtable ht = new Hashtable();
ht.put("a",rs.getString("id"));
ht.put("b",rs.getString("电子邮箱"));
ht.put("c",rs.getString("手机号"));
ht.put("d",rs.getString("预订房间数"));
ht.put("e",rs.getString("预订房间类型"));
ht.put("f",rs.getString("预订日期"));
data.addElement(ht);
}
}
catch(SQLException ex){
System.out.println("ex is "+ex);
}
catch (Exception E){
System.out.println("Service Error: "+E);
}
finally{
if (rs!=null){
try { rs.close();} catch (Exception ignore){ };
}
if (stmt!=null){
try { stmt.close();} catch (Exception ignore){ };
}
if (con!=null){
try { con.close();} catch (Exception ignore){ };
}
}//finally
return data;
}
public Vector LBookUserbytype(String roomtype){
Connection con = null;
Vector data = new Vector();
init();
try{
con = ds.getConnection();
//必须这样设置以对结果集进行指针操作
stmt = con.createStatement();
rs=stmt.executeQuery("select id,电子邮箱,手机号,预订房间数,预订房间类型,预订日期 from Hotel_Book_User where 预订房间类型='"+roomtype+"'");
System.out.println("enter the Hotel_Book_User");
while (rs.next())
{
Hashtable ht = new Hashtable();
ht.put("a",rs.getString("id"));
ht.put("b",rs.getString("电子邮箱"));
ht.put("c",rs.getString("手机号"));
ht.put("d",rs.getString("预订房间数"));
ht.put("e",rs.getString("预订房间类型"));
ht.put("f",rs.getString("预订日期"));
data.addElement(ht);
}
}
catch(SQLException ex){
System.out.println("ex is "+ex);
}
catch (Exception E){
System.out.println("Service Error: "+E);
}
finally{
if (rs!=null){
try { rs.close();} catch (Exception ignore){ };
}
if (stmt!=null){
try { stmt.close();} catch (Exception ignore){ };
}
if (con!=null){
try { con.close();} catch (Exception ignore){ };
}
}//finally
return data;
}
public Vector LBookUserbydate(String bookdate){
Connection con = null;
Vector data = new Vector();
init();
try{
con = ds.getConnection();
//必须这样设置以对结果集进行指针操作
stmt = con.createStatement();
rs=stmt.executeQuery("select id,电子邮箱,手机号,预订房间数,预订房间类型,预订日期 from Hotel_Book_User where 预订日期='"+bookdate+"'");
System.out.println("enter the Hotel_Book_User");
while (rs.next())
{
Hashtable ht = new Hashtable();
ht.put("a",rs.getString("id"));
ht.put("b",rs.getString("电子邮箱"));
ht.put("c",rs.getString("手机号"));
ht.put("d",rs.getString("预订房间数"));
ht.put("e",rs.getString("预订房间类型"));
ht.put("f",rs.getString("预订日期"));
data.addElement(ht);
}
}
catch(SQLException ex){
System.out.println("ex is "+ex);
}
catch (Exception E){
System.out.println("Service Error: "+E);
}
finally{
if (rs!=null){
try { rs.close();} catch (Exception ignore){ };
}
if (stmt!=null){
try { stmt.close();} catch (Exception ignore){ };
}
if (con!=null){
try { con.close();} catch (Exception ignore){ };
}
}//finally
return data;
}
public Vector LHotelUserInfo(String idcard){
Connection con = null;
Vector data = new Vector();
init();
try{
con = ds.getConnection();
//必须这样设置以对结果集进行指针操作
stmt = con.createStatement();
rs=stmt.executeQuery("select 用户名,性别,身份证,是否预订,入住日期,入住房间类型,入住房间号,入住房间数量,入住天数,是否结账,结账日期,是否打印发票,预交费,消费额,是否欠费,欠费额度 from Hotel_User_Info where 身份证='"+idcard+"'");
System.out.println("enter the hotel_user_info");
while (rs.next())
{
Hashtable ht = new Hashtable();
ht.put("a",rs.getString("用户名"));
ht.put("b",rs.getString("性别"));
ht.put("c",rs.getString("身份证"));
ht.put("d",rs.getString("是否预订"));
ht.put("e",rs.getString("入住日期"));
ht.put("f",rs.getString("入住房间类型"));
ht.put("g",rs.getString("入住房间号"));
ht.put("h",rs.getString("入住房间数量"));
ht.put("i",rs.getString("入住天数"));
ht.put("j",rs.getString("是否结账"));
ht.put("k",rs.getString("结账日期"));
ht.put("l",rs.getString("是否打印发票"));
ht.put("m",rs.getString("预交费"));
ht.put("n",rs.getString("消费额"));
ht.put("o",rs.getString("是否欠费"));
ht.put("p",rs.getString("欠费额度"));
data.addElement(ht);
}
}
catch(SQLException ex){
System.out.println("ex is "+ex);
}
catch (Exception E){
System.out.println("Service Error: "+E);
}
finally{
if (rs!=null){
try { rs.close();} catch (Exception ignore){ };
}
if (stmt!=null){
try { stmt.close();} catch (Exception ignore){ };
}
if (con!=null){
try { con.close();} catch (Exception ignore){ };
}
}//finally
return data;
}
public Vector LHotelAdministor(String name,String password){
Connection con = null;
Vector data = new Vector();
init();
try{
con = ds.getConnection();
//必须这样设置以对结果集进行指针操作
stmt = con.createStatement();
rs=stmt.executeQuery("select user_name,user_password,super_password,user_sex from Hotel_Administor where user_name='"+name+"' and user_password='"+password+"'");
System.out.println("enter the hotel_administor");
while (rs.next())
{
Hashtable ht = new Hashtable();
ht.put("a",rs.getString("user_name"));
ht.put("b",rs.getString("user_password"));
ht.put("c",rs.getString("super_password"));
ht.put("d",rs.getString("user_sex"));
data.addElement(ht);
}
}
catch(SQLException ex){
System.out.println("ex is "+ex);
}
catch (Exception E){
System.out.println("Service Error: "+E);
}
finally{
if (rs!=null){
try { rs.close();} catch (Exception ignore){ };
}
if (stmt!=null){
try { stmt.close();} catch (Exception ignore){ };
}
if (con!=null){
try { con.close();} catch (Exception ignore){ };
}
}//finally
return data;
}
public String login(String name,String password,String spassword){
Connection con = null;
Vector data = new Vector();
String token="no";
init();
try{
con = ds.getConnection();
stmt = con.createStatement();
rs=stmt.executeQuery("select * from Hotel_Administor where user_name='"+name+"' and user_password='"+password+"' and super_password='"+spassword+"'");
System.out.println("enter the login");
while (rs.next())
{
token="yes";
}
}
catch(SQLException ex){
System.out.println("ex is "+ex);
}
catch (Exception E){
System.out.println("Service Error: "+E);
}
finally{
if (rs!=null){
try { rs.close();} catch (Exception ignore){ };
}
if (stmt!=null){
try { stmt.close();} catch (Exception ignore){ };
}
if (con!=null){
try { con.close();} catch (Exception ignore){ };
}
}
return token;
}
public String checkid(String id){
Connection con = null;
Vector data = new Vector();
String token="no";
init();
try{
con = ds.getConnection();
stmt = con.createStatement();
rs=stmt.executeQuery("select * from Hotel_Book_User where id='"+id+"'");
System.out.println("check the id");
while (rs.next())
{
token="yes";
}
}
catch(SQLException ex){
System.out.println("ex is "+ex);
}
catch (Exception E){
System.out.println("Service Error: "+E);
}
finally{
if (rs!=null){
try { rs.close();} catch (Exception ignore){ };
}
if (stmt!=null){
try { stmt.close();} catch (Exception ignore){ };
}
if (con!=null){
try { con.close();} catch (Exception ignore){ };
}
}
return token;
}
/**
*用户信息的创建
*/
public int CHotelBookUser(String id,String email,String tel,String booksum,String bookroomtype,String bookdate)
{
Connection con = null;
int flag=0;
init();
try{
con = ds.getConnection();
pstmt=con.prepareStatement("insert into Hotel_Book_User (id,电子邮箱,手机号,预订房间数,预订房间类型,预订日期) values (?,?,?,?,?,?)");
pstmt.setString(1,id);
pstmt.setString(2,email);
pstmt.setString(3,tel);
pstmt.setString(4,booksum);
pstmt.setString(5,bookroomtype);
pstmt.setString(6,bookdate);
flag = pstmt.executeUpdate();
}//end try
catch (SQLException ex){
System.out.println("sql error: "+ex);
}
catch (Exception E){
System.out.println("Service Error: "+E);
}
finally{
if (rs!=null){
try { rs.close();} catch (Exception ignore){ };
}
if (pstmt!=null){
try { pstmt.close();} catch (Exception ignore){ };
}
if (con!=null){
try { con.close();} catch (Exception ignore){ };
}
}//finally
return flag;
}
public int CHotelUserInfo(String name,String sex,String idcard,String isbooked,String indate,String inroomtype,String inroomno,String inroomsum,String inday,String isbalancecount,String countdate,String isprinted,String prepay,String moneytotal,String isdebt,String debtsum){
Connection con = null;
int flag=0;
init();
try{
con = ds.getConnection();
pstmt = con.prepareStatement("insert into Hotel_User_Info (用户名,性别,身份证,是否预订,入住日期,入住房间类型,入住房间号,入住房间数量,入住天数,是否结账,结账日期,是否打印发票,预交费,消费额,是否欠费,欠费额度) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
pstmt.setString(1,name);
pstmt.setString(2,sex);
pstmt.setString(3,idcard);
pstmt.setString(4,isbooked);
pstmt.setString(5,indate);
pstmt.setString(6,inroomtype);
pstmt.setString(7,inroomno);
pstmt.setString(8,inroomsum);
pstmt.setString(9,inday);
pstmt.setString(10,isbalancecount);
pstmt.setString(11,countdate);
pstmt.setString(12,isprinted);
pstmt.setString(13,prepay);
pstmt.setString(14,moneytotal);
pstmt.setString(15,isdebt);
pstmt.setString(16,debtsum);
flag = pstmt.executeUpdate();
}//end try
catch (SQLException ex){
System.out.println("sql error: "+ex);
}
catch (Exception E){
System.out.println("Service Error: "+E);
}
finally{
if (rs!=null){
try { rs.close();} catch (Exception ignore){ };
}
if (pstmt!=null){
try { pstmt.close();} catch (Exception ignore){ };
}
if (con!=null){
try { con.close();} catch (Exception ignore){ };
}
}//finally
return flag;
}
public int CHotelAdministor(String name,String password,String spassword,String sex){
Connection con = null;
int flag=0;
init();
try{
con = ds.getConnection();
pstmt=con.prepareStatement("insert into Hotel_Administor (user_name,user_password,super_password,user_sex) values (?,?,?,?)");
pstmt.setString(1,name);
pstmt.setString(2,password);
pstmt.setString(3,spassword);
pstmt.setString(4,sex);
flag=pstmt.executeUpdate();
}//end try
catch (SQLException ex){
System.out.println("sql error: "+ex);
}
catch (Exception E){
System.out.println("Service Error: "+E);
}
finally{
if (rs!=null){
try { rs.close();} catch (Exception ignore){ };
}
if (pstmt!=null){
try { pstmt.close();} catch (Exception ignore){ };
}
if (con!=null){
try { con.close();} catch (Exception ignore){ };
}
}//finally
return flag;
}
public int CHotelRoomInfo(String roomtype,String roomprice,String roomtotal,String remaintoday,String remaintomorrow,String remainaftertomorrow,String remaininthird,String announcement){
Connection con = null;
int flag=0;
init();
try{
con = ds.getConnection();
pstmt=con.prepareStatement("insert into Hotel_Room_Info (RoomType,RoomPrice,RoomTotal,RemainToday,RemainTomorrow,RemainAfterTomorrow,RemainInThird,Announcement) values (?,?,?,?,?,?,?,?)");
pstmt.setString(1,roomtype);
pstmt.setString(2,roomprice);
pstmt.setString(3,roomtotal);
pstmt.setString(4,remaintoday);
pstmt.setString(5,remaintomorrow);
pstmt.setString(6,remainaftertomorrow);
pstmt.setString(7,remaininthird);
pstmt.setString(8,announcement);
flag=pstmt.executeUpdate();
}//end try
catch (SQLException ex){
System.out.println("sql error: "+ex);
}
catch (Exception E){
System.out.println("Service Error: "+E);
}
finally{
if (rs!=null){
try { rs.close();} catch (Exception ignore){ };
}
if (pstmt!=null){
try { pstmt.close();} catch (Exception ignore){ };
}
if (con!=null){
try { con.close();} catch (Exception ignore){ };
}
}//finally
return flag;
}
public int CHotelRoom(String roomid,String thisroomtype,String roomprice,String isempty,String useridcard){
Connection con = null;
int flag=0;
init();
try{
con = ds.getConnection();
pstmt = con.prepareStatement("insert into Hotel_Room (RoomID,RoomType,RoomPrice,IsEmpty,User_IdCard) values (?,?,?,?,?)");
pstmt.setString(1,roomid);
pstmt.setString(2,thisroomtype);
pstmt.setString(3,roomprice);
pstmt.setString(4,isempty);
pstmt.setString(5,useridcard);
flag=pstmt.executeUpdate();
}//end try
catch (SQLException ex){
System.out.println("sql error: "+ex);
}
catch (Exception E){
System.out.println("Service Error: "+E);
}
finally{
if (rs!=null){
try { rs.close();} catch (Exception ignore){ };
}
if (pstmt!=null){
try { pstmt.close();} catch (Exception ignore){ };
}
if (con!=null){
try { con.close();} catch (Exception ignore){ };
}
}//finally
return flag;
}
public int DBookUserBydate(String bookdate){
Connection con = null;
init();
int flag = 0;
try{
con = ds.getConnection();
pstmt = con.prepareStatement("delete from Hotel_Book_User where 预订日期=?");
pstmt.setString(1,bookdate);
flag = pstmt.executeUpdate();
System.out.println("delete bookuser by bookdate successfully!");
}//end try
catch (SQLException ex){
System.out.println("sql error: "+ex);
}
catch (Exception E){
System.out.println("Service Error: "+E);
}
finally{
if (rs!=null){
try { rs.close();} catch (Exception ignore){ };
}
if (pstmt!=null){
try { pstmt.close();} catch (Exception ignore){ };
}
if (con!=null){
try { con.close();} catch (Exception ignore){ };
}
}//finally
return flag;
}
public int DHotelBookUser(String id){
Connection con = null;
init();
int flag = 0;
try{
con = ds.getConnection();
pstmt = con.prepareStatement("delete from Hotel_Book_User where id=?");
pstmt.setString(1,id);
flag = pstmt.executeUpdate();
}//end try
catch (SQLException ex){
System.out.println("sql error: "+ex);
}
catch (Exception E){
System.out.println("Service Error: "+E);
}
finally{
if (rs!=null){
try { rs.close();} catch (Exception ignore){ };
}
if (pstmt!=null){
try { pstmt.close();} catch (Exception ignore){ };
}
if (con!=null){
try { con.close();} catch (Exception ignore){ };
}
}//finally
return flag;
}
public int DBookByRoomType(String inroomtype){
Connection con = null;
init();
int flag = 0;
try{
con = ds.getConnection();
pstmt = con.prepareStatement("delete from Hotel_Book_User where 预订房间类型=?");
pstmt.setString(1,inroomtype);
flag = pstmt.executeUpdate();
}//end try
catch (SQLException ex){
System.out.println("sql error: "+ex);
}
catch (Exception E){
System.out.println("Service Error: "+E);
}
finally{
if (rs!=null){
try { rs.close();} catch (Exception ignore){ };
}
if (pstmt!=null){
try { pstmt.close();} catch (Exception ignore){ };
}
if (con!=null){
try { con.close();} catch (Exception ignore){ };
}
}//finally
return flag;
}
public int DHotelRoomInfo(String roomtype){
Connection con = null;
init();
int flag = 0;
try{
con = ds.getConnection();
pstmt = con.prepareStatement("delete from Hotel_Room_Info where RoomType=?");
pstmt.setString(1,roomtype);
flag = pstmt.executeUpdate();
}//end try
catch (SQLException ex){
System.out.println("sql error: "+ex);
}
catch (Exception E){
System.out.println("Service Error: "+E);
}
finally{
if (rs!=null){
try { rs.close();} catch (Exception ignore){ };
}
if (pstmt!=null){
try { pstmt.close();} catch (Exception ignore){ };
}
if (con!=null){
try { con.close();} catch (Exception ignore){ };
}
}//finally
return flag;
}
public int DHotelUserInfo(String idcard){
Connection con = null;
init();
int flag = 0;
try{
con = ds.getConnection();
pstmt = con.prepareStatement("delete from Hotel_User_Info where 身份证=?");
pstmt.setString(1,idcard);
flag = pstmt.executeUpdate();
}//end try
catch (SQLException ex){
System.out.println("sql error: "+ex);
}
catch (Exception E){
System.out.println("Service Error: "+E);
}
finally{
if (rs!=null){
try { rs.close();} catch (Exception ignore){ };
}
if (pstmt!=null){
try { pstmt.close();} catch (Exception ignore){ };
}
if (con!=null){
try { con.close();} catch (Exception ignore){ };
}
}//finally
return flag;
}
public int DHotelRoom(String roomid){
Connection con = null;
init();
int flag = 0;
try{
con = ds.getConnection();
pstmt = con.prepareStatement("delete from Hotel_Room where RoomID=?");
pstmt.setString(1,roomid);
flag = pstmt.executeUpdate();
}//end try
catch (SQLException ex){
System.out.println("sql error: "+ex);
}
catch (Exception E){
System.out.println("Service Error: "+E);
}
finally{
if (rs!=null){
try { rs.close();} catch (Exception ignore){ };
}
if (pstmt!=null){
try { pstmt.close();} catch (Exception ignore){ };
}
if (con!=null){
try { con.close();} catch (Exception ignore){ };
}
}//finally
return flag;
}
public int DHotelAdministor(String name){
Connection con = null;
init();
int flag = 0;
try{
con = ds.getConnection();
pstmt = con.prepareStatement("delete from Hotel_Administor where user_name=?");
pstmt.setString(1,name);
flag = pstmt.executeUpdate();
}//end try
catch (SQLException ex){
System.out.println("sql error: "+ex);
}
catch (Exception E){
System.out.println("Service Error: "+E);
}
finally{
if (rs!=null){
try { rs.close();} catch (Exception ignore){ };
}
if (pstmt!=null){
try { pstmt.close();} catch (Exception ignore){ };
}
if (con!=null){
try { con.close();} catch (Exception ignore){ };
}
}//finally
return flag;
}
public int MHotelRoomInfo(String roomprice,String roomtotal,String remaintoday,String remaintomorrow,String remainaftertomorrow,String remaininthird,String announcement,String roomtype){
Connection con = null;
init();
int flag = 0;
try{
con = ds.getConnection();
pstmt = con.prepareStatement("update Hotel_Room_Info set RoomPrice=?,RoomTotal=?,RemainToday=?,RemainTomorrow=?,RemainAfterTomorrow=?,RemainInThird=?,Announcement=? where RoomType=?");
pstmt.setString(1,roomprice);
pstmt.setString(2,roomtotal);
pstmt.setString(3,remaintoday);
pstmt.setString(4,remaintomorrow);
pstmt.setString(5,remainaftertomorrow);
pstmt.setString(6,remaininthird);
pstmt.setString(7,announcement);
pstmt.setString(8,roomtype);
flag = pstmt.executeUpdate();
}//end try
catch (SQLException ex){
System.out.println("sql error: "+ex);
}
catch (Exception E){
System.out.println("Service Error: "+E);
}
finally{
if (rs!=null){
try { rs.close();} catch (Exception ignore){ };
}
if (pstmt!=null){
try { pstmt.close();} catch (Exception ignore){ };
}
if (con!=null){
try { con.close();} catch (Exception ignore){ };
}
}//finally
return flag;
}
public int MHotelRoomInfoA(String announcement,String roomtype){
Connection con = null;
init();
int flag = 0;
try{
con = ds.getConnection();
pstmt = con.prepareStatement("update Hotel_Room_Info set Announcement=? where RoomType=?");
pstmt.setString(1,announcement);
pstmt.setString(2,roomtype);
flag = pstmt.executeUpdate();
}//end try
catch (SQLException ex){
System.out.println("sql error: "+ex);
}
catch (Exception E){
System.out.println("Service Error: "+E);
}
finally{
if (rs!=null){
try { rs.close();} catch (Exception ignore){ };
}
if (pstmt!=null){
try { pstmt.close();} catch (Exception ignore){ };
}
if (con!=null){
try { con.close();} catch (Exception ignore){ };
}
}//finally
return flag;
}
public int MHotelRoomInfoT(String roomtotal,String roomtype){
Connection con = null;
init();
int flag = 0;
try{
con = ds.getConnection();
pstmt = con.prepareStatement("update Hotel_Room_Info set RoomTotal=? where RoomType=?");
pstmt.setString(1,roomtotal);
pstmt.setString(2,roomtype);
flag = pstmt.executeUpdate();
}//end try
catch (SQLException ex){
System.out.println("sql error: "+ex);
}
catch (Exception E){
System.out.println("Service Error: "+E);
}
finally{
if (rs!=null){
try { rs.close();} catch (Exception ignore){ };
}
if (pstmt!=null){
try { pstmt.close();} catch (Exception ignore){ };
}
if (con!=null){
try { con.close();} catch (Exception ignore){ };
}
}//finally
return flag;
}
public int MHotelRoomInfoP(String roomprice,String roomtype){
Connection con = null;
init();
int flag = 0;
try{
con = ds.getConnection();
pstmt = con.prepareStatement("update Hotel_Room_Info set RoomPrice=? where RoomType=?");
pstmt.setString(1,roomprice);
pstmt.setString(2,roomtype);
flag = pstmt.executeUpdate();
}//end try
catch (SQLException ex){
System.out.println("sql error: "+ex);
}
catch (Exception E){
System.out.println("Service Error: "+E);
}
finally{
if (rs!=null){
try { rs.close();} catch (Exception ignore){ };
}
if (pstmt!=null){
try { pstmt.close();} catch (Exception ignore){ };
}
if (con!=null){
try { con.close();} catch (Exception ignore){ };
}
}//finally
return flag;
}
public int MRoomInfoNO(String bookdate1,String oldsum1,String booksum1,String roomtype1){
Connection con = null;
init();
int flag = 0;
String newsum="";
int a=0;
int b=0;
int c=0;
a=java.lang.Integer.parseInt(oldsum1);
b=java.lang.Integer.parseInt(booksum1);
c=a-b;
if(c>=0){
newsum=java.lang.Integer.toString(c);
try{
con = ds.getConnection();
pstmt = con.prepareStatement("update Hotel_Room_Info set "+bookdate1+"=? where RoomType=?");
pstmt.setString(1,newsum);
pstmt.setString(2,roomtype1);
flag = pstmt.executeUpdate();
System.out.println("update roomremain successfully!");
}//end try
catch (SQLException ex){
System.out.println("sql error: "+ex);
}
catch (Exception E){
System.out.println("Service Error: "+E);
}
finally{
if (rs!=null){
try { rs.close();} catch (Exception ignore){ };
}
if (pstmt!=null){
try { pstmt.close();} catch (Exception ignore){ };
}
if (con!=null){
try { con.close();} catch (Exception ignore){ };
}
}//finally
}else{
flag=0;
}
return flag;
}
public int MDRoomInfoNO(String bookdate2,String oldsum2,String booksum2,String roomtype2){
Connection con = null;
init();
int flag = 0;
String newsum="";
int a=0;
int b=0;
int c=0;
a=java.lang.Integer.parseInt(oldsum2);
b=java.lang.Integer.parseInt(booksum2);
c=a+b;
newsum=java.lang.Integer.toString(c);
try{
con = ds.getConnection();
pstmt = con.prepareStatement("update Hotel_Room_Info set "+bookdate2+"=? where RoomType=?");
pstmt.setString(1,newsum);
pstmt.setString(2,roomtype2);
flag = pstmt.executeUpdate();
System.out.println("update roomremain successfully!");
}//end try
catch (SQLException ex){
System.out.println("sql error: "+ex);
}
catch (Exception E){
System.out.println("Service Error: "+E);
}
finally{
if (rs!=null){
try { rs.close();} catch (Exception ignore){ };
}
if (pstmt!=null){
try { pstmt.close();} catch (Exception ignore){ };
}
if (con!=null){
try { con.close();} catch (Exception ignore){ };
}
}//finally
return flag;
}
public int MHotelRoomInfoR(String remaintoday,String remaintomorrow,String remainaftertomorrow,String remaininthird,String roomtype){
Connection con = null;
init();
int flag = 0;
try{
con = ds.getConnection();
pstmt = con.prepareStatement("update Hotel_Room_Info set RemainToday=?,RemainTomorrow=?,RemainAfterTomorrow=?,RemainInThird=? where RoomType=?");
pstmt.setString(1,remaintoday);
pstmt.setString(2,remaintomorrow);
pstmt.setString(3,remainaftertomorrow);
pstmt.setString(4,remaininthird);
pstmt.setString(5,roomtype);
flag = pstmt.executeUpdate();
}//end try
catch (SQLException ex){
System.out.println("sql error: "+ex);
}
catch (Exception E){
System.out.println("Service Error: "+E);
}
finally{
if (rs!=null){
try { rs.close();} catch (Exception ignore){ };
}
if (pstmt!=null){
try { pstmt.close();} catch (Exception ignore){ };
}
if (con!=null){
try { con.close();} catch (Exception ignore){ };
}
}//finally
return flag;
}
public int MHotelAdministor(String password,String spassword,String name){
Connection con = null;
int flag=0;
init();
try{
con = ds.getConnection();
pstmt=con.prepareStatement("update Hotel_Administor set user_password=?,super_password=? where user_name=?");
pstmt.setString(1,password);
pstmt.setString(2,spassword);
pstmt.setString(3,name);
flag=pstmt.executeUpdate();
}//end try
catch (SQLException ex){
System.out.println("sql error: "+ex);
}
catch (Exception E){
System.out.println("Service Error: "+E);
}
finally{
if (rs!=null){
try { rs.close();} catch (Exception ignore){ };
}
if (pstmt!=null){
try { pstmt.close();} catch (Exception ignore){ };
}
if (con!=null){
try { con.close();} catch (Exception ignore){ };
}
}//finally
return flag;
}
public int MHotelBookUser(String booksum,String bookroomtype,String bookdate,String id)
{
Connection con = null;
int flag=0;
init();
try{
con = ds.getConnection();
pstmt=con.prepareStatement("update Hotel_Book_User set 预订房间数=?,预订房间类型=?,预订日期=? where id=?");
pstmt.setString(1,booksum);
pstmt.setString(2,bookroomtype);
pstmt.setString(3,bookdate);
pstmt.setString(4,id);
flag = pstmt.executeUpdate();
}//end try
catch (SQLException ex){
System.out.println("sql error: "+ex);
}
catch (Exception E){
System.out.println("Service Error: "+E);
}
finally{
if (rs!=null){
try { rs.close();} catch (Exception ignore){ };
}
if (pstmt!=null){
try { pstmt.close();} catch (Exception ignore){ };
}
if (con!=null){
try { con.close();} catch (Exception ignore){ };
}
}//finally
return flag;
}
public int MchangeRoom(String inroomtype,String inroomno,String inroomsum,String idcard){
Connection con = null;
int flag=0;
init();
try{
con = ds.getConnection();
pstmt = con.prepareStatement("update Hotel_User_Info set 入住房间类型=?,入住房间号=?,入住房间数量=? where 身份证=?");
pstmt.setString(1,inroomtype);
pstmt.setString(2,inroomno);
pstmt.setString(3,inroomsum);
pstmt.setString(4,idcard);
flag = pstmt.executeUpdate();
}//end try
catch (SQLException ex){
System.out.println("sql error: "+ex);
}
catch (Exception E){
System.out.println("Service Error: "+E);
}
finally{
if (rs!=null){
try { rs.close();} catch (Exception ignore){ };
}
if (pstmt!=null){
try { pstmt.close();} catch (Exception ignore){ };
}
if (con!=null){
try { con.close();} catch (Exception ignore){ };
}
}//finally
return flag;
}
public int MHotelUserInfo_3(String inday,String isbalancecount,String countdate,String isprinted,String money,String isdebt,String debtsum,String idcard){
Connection con = null;
int flag=0;
init();
try{
con = ds.getConnection();
pstmt = con.prepareStatement("update Hotel_User_Info set 入住天数=?,是否结账=?,结账日期=?,是否打印发票=?,消费额=?,是否欠费=?,欠费额度=? where 身份证=?");
pstmt.setString(1,inday);
pstmt.setString(2,isbalancecount);
pstmt.setString(3,countdate);
pstmt.setString(4,isprinted);
pstmt.setString(5,money);
pstmt.setString(6,isdebt);
pstmt.setString(7,debtsum);
pstmt.setString(8,idcard);
flag = pstmt.executeUpdate();
}//end try
catch (SQLException ex){
System.out.println("sql error: "+ex);
}
catch (Exception E){
System.out.println("Service Error: "+E);
}
finally{
if (rs!=null){
try { rs.close();} catch (Exception ignore){ };
}
if (pstmt!=null){
try { pstmt.close();} catch (Exception ignore){ };
}
if (con!=null){
try { con.close();} catch (Exception ignore){ };
}
}//finally
return flag;
}
public int MHotelUserInfo_2(String prepay,String money,String idcard){
Connection con = null;
String newmoney="";
int a=0;
int b=0;
int c=0;
a=java.lang.Integer.parseInt(prepay);
b=java.lang.Integer.parseInt(money);
c=a+b;
newmoney=java.lang.Integer.toString(c);
int flag=0;
init();
try{
con = ds.getConnection();
pstmt = con.prepareStatement("update Hotel_User_Info set 预交费=?,消费额=? where 身份证=?");
pstmt.setString(1,prepay);
pstmt.setString(2,newmoney);
pstmt.setString(3,idcard);
flag = pstmt.executeUpdate();
}//end try
catch (SQLException ex){
System.out.println("sql error: "+ex);
}
catch (Exception E){
System.out.println("Service Error: "+E);
}
finally{
if (rs!=null){
try { rs.close();} catch (Exception ignore){ };
}
if (pstmt!=null){
try { pstmt.close();} catch (Exception ignore){ };
}
if (con!=null){
try { con.close();} catch (Exception ignore){ };
}
}//finally
return flag;
}
public int MHotelUserInfo_1(String inroomtype,String inroomno,String inroomsum,String money,String idcard){
Connection con = null;
int flag=0;
init();
try{
con = ds.getConnection();
pstmt = con.prepareStatement("update Hotel_User_Info set 入住房间类型=?,入住房间号=?,入住房间数量=?,消费额=? where and 身份证=?");
pstmt.setString(1,inroomtype);
pstmt.setString(2,inroomno);
pstmt.setString(3,inroomsum);
pstmt.setString(4,money);
pstmt.setString(5,idcard);
flag = pstmt.executeUpdate();
}//end try
catch (SQLException ex){
System.out.println("sql error: "+ex);
}
catch (Exception E){
System.out.println("Service Error: "+E);
}
finally{
if (rs!=null){
try { rs.close();} catch (Exception ignore){ };
}
if (pstmt!=null){
try { pstmt.close();} catch (Exception ignore){ };
}
if (con!=null){
try { con.close();} catch (Exception ignore){ };
}
}//finally
return flag;
}
public int MHotelRoom(String thisroomtype,String roomprice,String isempty,String useridcard,String roomid){
Connection con = null;
int flag=0;
init();
try{
con = ds.getConnection();
pstmt = con.prepareStatement("update Hotel_Room set RoomType=?,RoomPrice=?,IsEmpty=?,User_IdCard=? where RoomID=?");
pstmt.setString(1,thisroomtype);
pstmt.setString(2,roomprice);
pstmt.setString(3,isempty);
pstmt.setString(4,useridcard);
pstmt.setString(5,roomid);
flag=pstmt.executeUpdate();
}//end try
catch (SQLException ex){
System.out.println("sql error: "+ex);
}
catch (Exception E){
System.out.println("Service Error: "+E);
}
finally{
if (rs!=null){
try { rs.close();} catch (Exception ignore){ };
}
if (pstmt!=null){
try { pstmt.close();} catch (Exception ignore){ };
}
if (con!=null){
try { con.close();} catch (Exception ignore){ };
}
}//finally
return flag;
}
public int MHotelRoomU(String isempty,String roomid){
Connection con = null;
int flag=0;
init();
try{
con = ds.getConnection();
pstmt = con.prepareStatement("update Hotel_Room set IsEmpty=? where RoomID=?");
pstmt.setString(1,isempty);
pstmt.setString(2,roomid);
flag=pstmt.executeUpdate();
}//end try
catch (SQLException ex){
System.out.println("sql error: "+ex);
}
catch (Exception E){
System.out.println("Service Error: "+E);
}
finally{
if (rs!=null){
try { rs.close();} catch (Exception ignore){ };
}
if (pstmt!=null){
try { pstmt.close();} catch (Exception ignore){ };
}
if (con!=null){
try { con.close();} catch (Exception ignore){ };
}
}//finally
return flag;
}
}