package jbdc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import tools.DBUtil;

public class _4_delete {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Connection conn = DBUtil.getConn();
		PreparedStatement psmt = null;//预编译结果

		
		///    删除     //
		
		try {
			String sql = "delete from user where id= ? ";
			psmt = conn.prepareStatement(sql);
//			psmt.setInt(1,20003);//删除第一个?
			psmt.setString(1, "20004");
			int i = psmt.executeUpdate();//如果删除成功那么返回的值大于0,不成功就返回0
			if(i!=0)
				System.out.println("删除成功");
			else
				System.out.println("删除失败");
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
			
	}
}