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

📄 mysqlstoredaoimpl.java

📁 电子商务网站前台代码。基于开源软件编写
💻 JAVA
字号:
package dao;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class MySqlStoreDAOImpl extends CommonUserDAOImpl implements ShopDAO{
    private  Connection conn;   

	public boolean insertShopUser(ShopUserTO shopTO) {
		// TODO Auto-generated method stub
		//conn = this.getConnect();
		/*try {
			PreparedStatement preproc = conn.prepareStatement("insert usertable(userName,userPassword,role,realName,sex,e_Mail,address,phoneNum,userDescribe) values(?,?,?,?,?,?,?,?,?)");
			preproc.setString(1,shopTO.getName());
			preproc.setString(2,shopTO.getPassword());
			preproc.setString(3,shopTO.getRole());
			preproc.setString(4,shopTO.getRealname());
			preproc.setString(5,shopTO.getSex());
			preproc.setString(6,shopTO.getEmail());
			preproc.setString(7,shopTO.getAddress());
			preproc.setString(8,shopTO.getPhone());
			preproc.setString(9,shopTO.getDescribe());
	
			preproc.execute();
			
			CallableStatement callproc = conn.prepareCall("{call insertUser(?,?,?,?,?,?,?)}");
			callproc.setString("name",userTO.getName());
			callproc.setString("userpassword",userTO.getPassword());
			callproc.setString("role",userTO.getRole());
			callproc.setString("sex",userTO.getSex());			
			callproc.setString("telNum",userTO.getPhone());			
			callproc.setString("address",userTO.getAddress());	
			callproc.setString("email",userTO.getEmail());	
						
			callproc.execute();
			return true;
		}catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return false;
		}finally{
			try {
				conn.close();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}*/return false;
	}

	public boolean updateShopUser(ShopUserTO shopTO) {
		// TODO Auto-generated method stub
		conn = this.getConnect();
		/*try {			
			PreparedStatement preproc = conn.prepareStatement("update usertable set userPassword=?,role=?,sex=?,e_Mail=?,telNum=?,address=? where userName=?");
			preproc.setString(1,shopTO.getPassword());
			preproc.setString(2,shopTO.getRole());
			preproc.setString(3,shopTO.getSex());
			preproc.setString(4,shopTO.getEmail());
			preproc.setString(5,shopTO.getPhone());
			preproc.setString(6,shopTO.getAddress());
			preproc.setString(7,shopTO.getName());
			preproc.execute();
			return true;
		}catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return false;
		}finally{
			try {
				conn.close();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}		*/return false;
	}

	public ShopUserTO selectShopUser(String username) {
		// TODO Auto-generated method stub
		conn = this.getConnect();
		/*try {			
			PreparedStatement preproc = conn.prepareStatement("select userName,userPassword,role,realName,sex,e_Mail,address,phoneNum,userDescribe from usertable where userName=?");
			preproc.setString(1,username);		
			preproc.execute();
			ResultSet rs = preproc.getResultSet();
			
			if(rs.next()){
				ShopUserTO shopTo = new ShopUserTO();
				shopTo.setName(rs.getString("userName"));
				shopTo.setPassword(rs.getString("userPassword"));
				shopTo.setRole(rs.getString("role"));
				shopTo.setRealname(rs.getString("realName"));
				shopTo.setSex(rs.getString("sex"));
				shopTo.setEmail(rs.getString("e_Mail"));
				shopTo.setAddress(rs.getString("address"));
				shopTo.setPhone(rs.getString("phoneNum"));
				shopTo.setDescribe(rs.getString("userDescribe"));
				return shopTo;
			}else
				return null;
			
		}catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return null;
		}finally{
			try {
				conn.close();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}	*/return null;			
	}

	public boolean deleteShopUser(String username) {
		// TODO Auto-generated method stub
		conn = this.getConnect();
		/*try {
			CallableStatement callproc = conn.prepareCall("{call deleteUser(?)}");			
			callproc.setString("username",username);			
			callproc.execute();
			return true;
		}catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return false;
		}finally{
			try {
				conn.close();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}	*/return false;
	}

}

⌨️ 快捷键说明

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