预声明之删除

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

}

 

posted @ 2017-05-20 18:57  苏轼的红烧肉  阅读(123)  评论(0编辑  收藏  举报