查查

原创 2013年12月02日 13:54:45
public class UnisDao {

public void insertUser(UnisVo unisVo)
{
Statement st = null;
Connection conn = null;
try {
//Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");  //加载驱动
//conn = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;DatabaseName=unisdb","sa","sa"); //
conn = DbManage.getConnection();
st = conn.createStatement(); //发送指令集
String sql = "INSERT INTO tableunis (user_name,user_password,user_surepassword,user_sex,user_birth,user_hobby,user_native,user_introduce) VALUES ('"+unisVo.getUserName()+"','"+unisVo.getInputPassword()+"','"+unisVo.getSurePassword()+"','"+unisVo.getUserSex()+"','"+unisVo.getUserYear()+"年"+unisVo.getUserMonth()+"月"+unisVo.getUserDay()+"日"+"','"+unisVo.getUserEnioy()+"','"+unisVo.getProvinceInfo()+unisVo.getCityInfo()+"','"+unisVo.getUserIntroduce()+"')";
//System.out.println(sql);
st.executeUpdate(sql); // 无返回值

} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally
{
DbManage.closeDB(st, conn);
}
}

public ArrayList selectUser()
{
Statement st = null;
Connection conn = null;
ResultSet rs = null;
ArrayList unisList = new ArrayList();
try {
//Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");  //加载驱动
//conn = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;DatabaseName=unisdb","sa","sa"); //
conn = DbManage.getConnection();
st = conn.createStatement(); //发送指令集
String sql = "SELECT * FROM tableunis WHERE user_display = 1";  
rs = st.executeQuery(sql);
while(rs.next())
{
UnisVo unisVo = new UnisVo();
unisVo.setUserID(rs.getInt("user_id"));
unisVo.setUserName(rs.getString("user_name"));
unisVo.setInputPassword(rs.getString("user_password"));
unisVo.setSurePassword(rs.getString("user_surepassword"));
unisVo.setUserSex(rs.getString("user_sex"));
unisVo.setUserYear(rs.getString("user_birth"));
unisVo.setUserMonth(rs.getString("user_birth"));
unisVo.setUserDay(rs.getString("user_birth"));
unisVo.setUserEnioy(rs.getString("user_hobby"));
unisVo.setProvinceInfo(rs.getString("user_native"));
unisVo.setCityInfo(rs.getString("user_native"));
unisVo.setUserIntroduce(rs.getString("user_introduce"));
unisList.add(unisVo);

}

} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally
{
DbManage.closeDB(rs, st, conn);
}

return unisList;
}

public void deleteUser(String userID)
{
Statement st = null;
Connection conn = null;
try {
//Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");  //加载驱动
//conn = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;DatabaseName=unisdb","sa","sa"); //
conn = DbManage.getConnection();
st = conn.createStatement(); //发送指令集
String sql = "UPDATE tableunis SET user_display = 0 WHERE user_id = '"+userID+"'";
//System.out.println(sql);
st.executeUpdate(sql); // 无返回值

} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally
{
DbManage.closeDB(st, conn);
}
}

public UnisVo selectOneUser(String userID)
{
Statement st = null;
Connection conn = null;
ResultSet rs = null;
UnisVo unisVo = new UnisVo();
try {
//Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");  //加载驱动
//conn = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;DatabaseName=unisdb","sa","sa"); //
conn = DbManage.getConnection();
st = conn.createStatement(); //发送指令集
String sql = "SELECT * FROM tableunis WHERE user_display = 1 AND user_id = '"+userID+"'";  
rs = st.executeQuery(sql);
while(rs.next())
{

unisVo.setUserID(rs.getInt("user_id"));
unisVo.setUserName(rs.getString("user_name"));
unisVo.setInputPassword(rs.getString("user_password"));
unisVo.setSurePassword(rs.getString("user_surepassword"));
unisVo.setUserSex(rs.getString("user_sex"));
unisVo.setUserYear(rs.getString("user_birth"));
unisVo.setUserMonth(rs.getString("user_birth"));
unisVo.setUserDay(rs.getString("user_birth"));
unisVo.setUserEnioy(rs.getString("user_hobby"));
unisVo.setProvinceInfo(rs.getString("user_native"));
unisVo.setCityInfo(rs.getString("user_native"));
unisVo.setUserIntroduce(rs.getString("user_introduce"));

}

} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally
{
DbManage.closeDB(rs, st, conn);
}

return unisVo;
}

public void deleteUsers(String[] deleteUserIds)
{
Statement st = null;
Connection conn = null;
try {
//Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");  //加载驱动
//conn = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;DatabaseName=unisdb","sa","sa"); //
conn = DbManage.getConnection();
st = conn.createStatement(); //发送指令集
for(int i=0;i<deleteUserIds.length;i++)
{
String sql = "UPDATE tableunis SET user_display = 0 WHERE user_id = '"+deleteUserIds[i]+"'";
//System.out.println(sql);
st.executeUpdate(sql); // 无返回值
}

} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally
{
DbManage.closeDB(st, conn);
}
}

public void updateUser(UnisVo unisVo)
{
Statement st = null;
Connection conn = null;
try {
//Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");  //加载驱动
//conn = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;DatabaseName=unisdb","sa","sa"); //
conn = DbManage.getConnection();
st = conn.createStatement(); //发送指令集
String sql = "UPDATE tableunis SET user_name = '"+unisVo.getUserName()+"',user_password = '"+unisVo.getInputPassword()+"',user_surepassword = '"+unisVo.getSurePassword()+"',user_sex = '"+unisVo.getUserSex()+"',user_birth='"+unisVo.getUserYear()+"年"+unisVo.getUserMonth()+"月"+unisVo.getUserDay()+"日"+"',user_hobby = '"+unisVo.getUserEnioy()+"',user_native = '"+unisVo.getProvinceInfo()+unisVo.getCityInfo()+"',user_introduce = '"+unisVo.getUserIntroduce()+"' WHERE user_id = '"+unisVo.getUserID()+"'";
//System.out.println(sql);
st.executeUpdate(sql); // 无返回值

} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally
{
DbManage.closeDB(st, conn);
}
}
版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

HTTP劫持后续查查xjcf168.com

劫持事件:手机版百度m.baidu.com被运营商劫持到xjcf168.com 中间有一个名为xjcf168.com的网站,下面我们来查查相关信息 备案数据 Whois信息 DNS服务器为商务...

我查查 并行数据处理应对突发流量

陈红州和赵立新曾供职于一家做图像传感器的公司,“最初我们只是将条码识别算法嵌入到芯片中,打算把芯片多卖几分钱。”陈红州笑言。随后他们试图围绕条码识别开发相应的数据库,但这一想法并未得到公司的认可,于是...

《查查看》

  • 2013-01-03 21:18
  • 2.99MB
  • 下载

查查看手机版

  • 2013-01-01 00:11
  • 2.92MB
  • 下载

第四周周赛——我查,我查,我查查查题解(来自poj2524,1664,1182,HDU1021,5524,5645)

A题: A题题目链接 题目描述: Ubiquitous Religions TimeLimit:5000MS  MemoryLimit:65536K 64-bit integer IO f...

是时候查查马云究竟拥有多少片“云”了!

阿里系又出了一单大新闻,6月30日,蚂蚁金服旗下用于淘宝、天猫的信用消费信贷产品——“花呗”的服务协议引发了轩然大波。让我们看看让人惊慌失措的《花呗用户服务合同》。这种“收集”数据的方式,无非是为了精...

eclipse快捷键大全 用的时候可以查查哈!(转载)

eclipse快捷键大全 (有重复,自己整理下)Ctrl+1 快速修复(最经典的快捷键,就不用多说了)Ctrl+D: 删除当前行 Ctrl+Alt+↓ 复制当前行到下一行(复制增加)Ctrl+Alt+...

我查查软件

  • 2014-09-20 13:15
  • 632KB
  • 下载

everest查查硬件检测

  • 2014-04-08 06:25
  • 692KB
  • 下载
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)