⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 orderbean.java

📁 JAVA网上书店的程序原代码,希望对大家偶用
💻 JAVA
字号:
package ebookshop.bean;

import java.io.Serializable;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Date;
import ebookshop.common.*;


public class OrderBean implements Serializable
{
	private String realName;
	private String address;
	private String postalcode;
	private String telephone;
	private Date date;
	private Integer cid;
	
	public OrderBean() {}
	
	public void setRealName(String realName) {this.realName=realName;}
	public void setAddress(String address) {this.address=address;}
	public void setPostalcode(String postalcode) {this.postalcode=postalcode;}
	public void setTelephone(String telephone) {this.telephone=telephone;}
	public void setDate(Date date) {this.date=date;}
	public void setCid(Integer cid) {this.cid=cid;}
	
	public String getRealName() {return this.realName;}
	public String getAddress() {return this.address;}
	public String getPostalcode() {return this.postalcode;}
	public String getTelephone() {return this.telephone;}
	public Date getDate() {return this.date;}
	public Integer getCid() {return this.cid;}
	
	//将用户的详细信息保存到数据库的eb_order表中,返出此次操作的oid
	public int saveUserInf(Integer cid,String realName,String address,String postalcode,String telephone,java.sql.Date date)
	{
		Connection con=new DataConnect().getConnection("netbookdata");
		String sqlStr="INSERT INTO eb_order (realName,address,postalcode,telephone,date,cid) VALUES('"+realName+
									"','"+address+"','"+postalcode+"','"+telephone+"','"+date+"','"+cid+"'"+")";
		String sql="select oid from eb_order where cid='"+cid+"'";
		System.out.println(sqlStr);
		
		PreparedStatement  pst=null;
		ResultSet rs =null;
		int oid=0;
		try {
				pst=con.prepareStatement(sqlStr);
			  	con.setAutoCommit(false);      //取消自动提交
				//System.out.println("hello1");
				pst.execute();
				con.commit();  //提交

				con.setAutoCommit(true);      //设为自动提交
				pst = con.prepareStatement(sql);
				rs=pst.executeQuery();
				while(rs.next()){
					oid=rs.getInt("oid");
					System.out.println(oid);
				}
				
				rs.close();
		        pst.close();
		        con.close();
		        
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		 	
		
		return oid;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -