package com.lianxi; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.util.Scanner; public class Shanchu { public static void main(String[] args) throws Exception { Class.forName("com.mysql.jdbc.Driver"); Connection conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/boooks","root","tiger"); PreparedStatement ps=conn.prepareStatement("delete from tb_user where userno=?"); Scanner s=new Scanner(System.in); System.out.println("请输入用户编号"); int no=s.nextInt(); ps.setInt(1, no); ps.execute(); conn.close(); } }
时间: 2024-11-05 01:49:14