首页 > 技术文章 > 预声明之删除

zyy1130 2017-05-20 18:57 原文

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();
        
    }

}

 

推荐阅读