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

📄 userimpl.java

📁 很多学校
💻 JAVA
字号:
package com.tarena.dao.ipml;import com.tarena.entity.*;import java.sql.Connection;import java.sql.PreparedStatement;import java.sql.ResultSet;import java.sql.SQLException;import com.tarena.util.*;import java.sql.*;import com.tarena.dao.*;	public class UserImpl implements UserDao{public void insert(User user){	Connection con = null;	PreparedStatement ps = null;	String sql = "insert into user_bo_1314"		+ " values(user_bo_1314.nextval,?,?,?,?,?,?)";	try {		con = JdbcUtil.getConnection();		con.setAutoCommit(false);		ps = con.prepareStatement(sql);		ps.setString(1, user.getName());		System.out.println("1111111111111111111"+user.getName());		ps.setString(2,user.getPassword());		System.out.println("1111111111111111111"+user.getPassword());		ps.setString(3, user.getAddress());		System.out.println("1111111111111111111"+user.getAddress());		ps.setString(4, user.getPostCode());		ps.setString(5, user.getEmail());		ps.setString(6, user.getPhone());		System.out.println("1111111111111111111"+user.getPhone());		ps.executeUpdate();		con.commit();		System.out.println("1111111111111111111");	} catch (SQLException e) {		System.out.println("error 插入用户失败");		e.printStackTrace();		if (con != null) {			try {				con.rollback();			} catch (SQLException e1) {				e1.printStackTrace();			}		}	}finally{		JdbcUtil.release(null, ps, con);	}}public void update(User user) {	Connection con = null;	PreparedStatement ps = null;	try{		con = JdbcUtil.getConnection();		String sql="update User_bo set password=?,address=?,postcode=?,email=?,phone=? where name='" + user.getName()+ "'";		ps = con.prepareStatement(sql);		ps.setString(1,user.getPassword());		System.out.println(user.getPassword()+"~~~~~~~");		ps.setString(2, user.getAddress());		System.out.println(user.getAddress()+"~~~~~~~");				ps.setString(3, user.getPostCode());				ps.setString(4, user.getEmail());				ps.setString(5, user.getPhone());				ps.executeUpdate();			}catch(Exception e){				e.printStackTrace();			}finally{				JdbcUtil.release(null, ps, con);			}		}}

⌨️ 快捷键说明

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