📄 mysqlshopdaoimpl.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 MySqlShopDAOImpl extends CommonUserDAOImpl implements ShopDAO{
private Connection conn;
public boolean insertShopUser(ShopUserTO userTO) {
// TODO Auto-generated method stub
conn = this.getConnect();
try {
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();
}
}
}
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();
}
} */
System.out.println("update");
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.setUserName(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"));
//System.out.println(shopTo)
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();
}
}
}
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 + -