//自己写的一个完整的带增删改查提交重置功能的表单代码。
package com.l16.test5;
import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;

public class MyFrame extends JFrame implements ActionListener {
 private JPanel panel = null;
 private JPanel sePanel = null;
 private JPanel hoPanel = null;
 private JPanel buPanel = null;
 private JPanel buPanel2 = null;
 private JPanel buPanel3 = null;
 //姓名
 private JLabel tilabel = null;
 private JLabel naLabel = null;
 private JTextField naTextField = null;
 //密码
 private JLabel paLabel = null;
 private JPasswordField passwordField = null;
 private JLabel paLabel2 = null;
 private JPasswordField passwordField2 = null;
 //性别 控制单选用ButtonGroup
 private JLabel seLabel = null;
 private JRadioButton maRadioButton = null;
 private JRadioButton feRadioButton = null;
 private ButtonGroup buttonGroup = null;
 //爱好
 private JLabel hoLabel = null;
 private JCheckBox eaCheckBox = null;
 private JCheckBox spCheckBox = null;
 private JCheckBox slCheckBox = null;
 
 //籍贯 下拉功能用Combobox
 private JLabel adLabel = null;
 private JComboBox comboBox = null;
 
 //自我介绍
 private JLabel shLabel = null;
 private JTextArea textArea = null;
 private JScrollPane scrollPane = null;
 
 //增删改查 提交 重置
 private JButton adButton = null;
 private JButton deButton = null;
 private JButton alButton = null;
 private JButton quButton = null;
 private JButton suButton = null;
 private JButton reButton = null;
 private void init() {
  
  this.setTitle("注册页面");
  this.setDefaultCloseOperation(this.EXIT_ON_CLOSE);
  Container content = this.getContentPane();
  this.panel = new JPanel(new GridBagLayout());
  content.add(panel);
  
  GridBagConstraints gbc = new GridBagConstraints();
  //标头
  this.tilabel = new JLabel("金智用户注册");
  this.tilabel.setFont(new Font("宋体", Font.BOLD, 26));
  gbc.gridx = 1;
  gbc.gridy = 0;
  this.panel.add(this.tilabel, gbc);
  //位置居右
  gbc.anchor = GridBagConstraints.EAST;
  //用户名
  this.naLabel = new JLabel("用户名:");
  this.naLabel.setFont(new Font("宋体", Font.BOLD, 20));
  gbc.gridx = 0;
  gbc.gridy = 1;
  this.panel.add(this.naLabel, gbc);
  this.naTextField = new JTextField(16);
  gbc.gridx = 1;
  gbc.gridy = 1;
  this.panel.add(this.naTextField, gbc);
  //密码1次
  this.paLabel = new JLabel("密  码:");
  this.paLabel.setFont(new Font("宋体", Font.BOLD, 20));
  gbc.gridx = 0;
  gbc.gridy = 2;
  this.panel.add(this.paLabel, gbc);
  this.passwordField = new JPasswordField(16);
  gbc.gridx = 1;
  gbc.gridy = 2;
  this.panel.add(this.passwordField, gbc);
  //密码2次
  this.paLabel2 = new JLabel("密 码2:");
  this.paLabel2.setFont(new Font("宋体", Font.BOLD, 20));
  gbc.gridx = 0;
  gbc.gridy = 3;
  this.panel.add(this.paLabel2, gbc);
  this.passwordField2 = new JPasswordField(16);
  gbc.gridx = 1;
  gbc.gridy = 3;
  this.panel.add(this.passwordField2, gbc);
  //性别
  this.seLabel = new JLabel("性  别:");
  this.seLabel.setFont(new Font("宋体", Font.BOLD, 20));
  gbc.gridx = 0;
  gbc.gridy = 4;
  this.panel.add(this.seLabel, gbc);
  this.maRadioButton = new JRadioButton("男", true);
  this.maRadioButton.setFont(new Font("宋体", Font.BOLD, 20));
  this.feRadioButton = new JRadioButton("女");
  this.feRadioButton.setFont(new Font("宋体", Font.BOLD, 20));
  this.sePanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 28, 0));
  this.sePanel.add(maRadioButton);
  this.sePanel.add(feRadioButton);
  this.buttonGroup = new ButtonGroup();
  this.buttonGroup.add(maRadioButton);
  this.buttonGroup.add(feRadioButton);
  gbc.gridx = 1;
  gbc.gridy = 4;
  this.panel.add(this.sePanel, gbc);
  //爱好
  this.hoLabel = new JLabel("爱  好:");
  this.hoLabel.setFont(new Font("宋体", Font.BOLD, 20));
  gbc.gridx = 0;
  gbc.gridy = 5;
  this.panel.add(this.hoLabel, gbc);
  this.hoPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0));
  this.eaCheckBox = new JCheckBox("吃饭");
  this.eaCheckBox.setFont(new Font("宋体", Font.BOLD, 16));
  this.spCheckBox = new JCheckBox("运动");
  this.spCheckBox.setFont(new Font("宋体", Font.BOLD, 16));
  this.slCheckBox = new JCheckBox("睡觉");
  this.slCheckBox.setFont(new Font("宋体", Font.BOLD, 16));
  this.hoPanel.add(eaCheckBox);
  this.hoPanel.add(spCheckBox);
  this.hoPanel.add(slCheckBox);
  gbc.gridx = 1;
  gbc.gridy = 5;
  this.panel.add(this.hoPanel, gbc);
  //籍贯
  this.adLabel = new JLabel("籍  贯:");
  this.adLabel.setFont(new Font("宋体", Font.BOLD, 20));
  gbc.gridx = 0;
  gbc.gridy = 6;
  this.panel.add(this.adLabel, gbc);
  String[] add = {"西安", "北京", "上海", "广州"};
  this.comboBox = new JComboBox(add);
  this.comboBox.setFont(new Font("宋体", Font.BOLD, 20));
  this.comboBox.setPreferredSize(new Dimension(176, 22));
  gbc.gridx = 1;
  gbc.gridy = 6;
  this.panel.add(this.comboBox, gbc);
  //自我介绍
  this.shLabel = new JLabel("介   绍:");
  this.shLabel.setFont(new Font("宋体", Font.BOLD, 20));
  gbc.gridx = 0;
  gbc.gridy = 7;
  this.panel.add(this.shLabel, gbc);
  this.textArea = new JTextArea("请在这里写你的自我介绍", 10, 22);
  this.textArea.setFont(new Font("宋体", Font.BOLD, 14));
  this.scrollPane = new JScrollPane(textArea);
  gbc.gridx = 1;
  gbc.gridy = 7;
  this.panel.add(this.scrollPane, gbc);
  
  //增删改查
  this.buPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 0, 0));
  this.adButton = new JButton("增");
  this.adButton.addActionListener(this);
  this.buPanel.add(this.adButton);
  gbc.gridx = 0;
  gbc.gridy = 8;
  this.panel.add(this.buPanel, gbc);
  
  this.buPanel2 = new JPanel(new FlowLayout(FlowLayout.LEFT, 10, 0));
  this.deButton = new JButton("删");
  this.deButton.addActionListener(this);
  this.alButton = new JButton("改");
  this.alButton.addActionListener(this);
  this.quButton = new JButton("查");
  this.quButton.addActionListener(this);
  this.buPanel2.add(this.deButton);
  this.buPanel2.add(this.alButton);
  this.buPanel2.add(this.quButton);
  gbc.gridx = 1;
  gbc.gridy = 8;
  this.panel.add(this.buPanel2, gbc);
  //提交和重置
  this.buPanel3 = new JPanel(new FlowLayout(FlowLayout.CENTER, 16 , 0));
  this.suButton = new JButton("提交");
  this.suButton.addActionListener(this);
  this.reButton = new JButton("重置");
  this.reButton.addActionListener(this);
  this.buPanel3.add(suButton);
  this.buPanel3.add(reButton);
  gbc.gridx = 1;
  gbc.gridy = 9;
  this.panel.add(this.buPanel3, gbc);
  
  
  
  
 }
 public MyFrame() {
  
  this.init();
 }
 public static void main(String[] args) {
  MyFrame frame = new MyFrame();
  frame.setBounds(100, 20, 400, 600);
  frame.setVisible(true);
 }
 @Override
 public void actionPerformed(ActionEvent e) {
  //声明数据库的三个对象,
  Connection conn = null;//连接对象
  Statement sta = null;//执行对象
  ResultSet rs = null;//结果集对象
  //增加一条记录开始***********************************************
  //首先必须查数据库看有没有主键相同的,有的话提醒用户,不能插入同名的两条记录。
  if(e.getSource() == this.adButton) {
   
   //获取姓名
   String username = this.naTextField.getText();
   //校验姓名
   if(username != null && username.length() <= 0) {
    JOptionPane.showMessageDialog(this, "用户名不能为空!", "提示框", JOptionPane.WARNING_MESSAGE);
    return;
   }
   //获取一次密码
   String password1 = String.valueOf(this.passwordField.getPassword());
   //获取二次密码
   String password2 = String.valueOf(this.passwordField2.getPassword());
   //校验密码
   if(password1 != null  && password1.length() <= 0 ) {
    JOptionPane.showMessageDialog(this, "密码不能为空");
    return;
   }
   if(password2 != null && password2.length() <= 0) {
    JOptionPane.showMessageDialog(this, "密码不能为空");
    return;
   }
   if(!(password1.equals(password2))) {
    JOptionPane.showMessageDialog(this, "两次密码不一致,请重新输入二次密码");
    return;
   }
   //获取性别
   String sex = null;
   if(this.maRadioButton.isSelected()) {
     sex = "男";
   } else {
    sex = "女";
   }
   //获取爱好
   String eat = null;
   if(this.eaCheckBox.isSelected()) {
    eat = "吃饭";
   }
   String sport = null;
   if(this.spCheckBox.isSelected()) {
    sport = "运动";
   }
   String sleep = null;
   if(this.slCheckBox.isSelected()) {
    sleep = "睡觉";
   }
   //获取户籍地

String address = this.comboBox.getSelectedItem().toString();
   //获取自我介绍
   String showMe = this.textArea.getText();
   //拼接增加记录的Sql
   String addSql = "insert into userTable values('"+username+"', '"+password1+"', '"+sex+"',"
     + " '"+eat+"', '"+sport+"', '"+sleep+"',"
       + " '"+address+"', '"+showMe+"')";
   String queSql = "select * from userTable where nameuser = '"+username+"'";
   //连接数据库
   try {
    Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
    conn = DriverManager.getConnection("jdbc:sqlserver://127.0.0.1:1433;DatabaseName=student", "sa", "sa");
    sta = conn.createStatement();
    rs = sta.executeQuery(queSql);
    if(rs.next() == true) {
     JOptionPane.showMessageDialog(this, "数据库中已存在此人,不能重复插入");
     return;
    }
    int a = sta.executeUpdate(addSql);
    if(a > 0) {
     JOptionPane.showMessageDialog(this, "恭喜您,插入记录成功!");
    }
   } catch (ClassNotFoundException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
   } catch (SQLException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
   } finally {
    try {
     if(rs != null) {
      rs.close();
      rs = null;
     }
     if(sta != null) {
      sta.close();
      sta = null;
     }
     if(conn != null) {
      conn.close();
      conn = null;
     }
    } catch (SQLException e1) {
     // TODO Auto-generated catch block
     e1.printStackTrace();
    }
   }
   //清空表单内的数据
   this.naTextField.setText("");
   this.passwordField.setText("");
   this.passwordField2.setText("");
   //默认选择男生
   this.maRadioButton.setSelected(true);
   this.eaCheckBox.setSelected(false);
   this.spCheckBox.setSelected(false);
   this.slCheckBox.setSelected(false);
   this.comboBox.setSelectedItem("西安");
   this.textArea.setText("请在这里写你的自我介绍");
  
  //删除一条记录开始**********************************************
  } else if(e.getSource() == this.deButton) {
   //根据姓名来删除记录,没有就提示数据库没有
   String username = JOptionPane.showInputDialog("请输入您要删除的名字");
   //查询数据库
   String queSql = "select * from userTable where nameuser = '"+username+"'";
   String delSql = "delete from userTable where nameuser = '"+username+"'";
   //连接数据库
   try {
    Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
    conn = DriverManager.getConnection("jdbc:sqlserver://127.0.0.1:1433;DatabaseName=student", "sa", "sa");
    sta = conn.createStatement();
    rs = sta.executeQuery(queSql);
    //校验看数据库是否有此人
    if(rs.next() == false) {
     JOptionPane.showMessageDialog(this, "查无此人,请您核对后再输入");
    } else {
     int d = sta.executeUpdate(delSql);
     if(d > 0) {
      JOptionPane.showMessageDialog(this, "删除记录成功");
     }
    }
   } catch (ClassNotFoundException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
   } catch (SQLException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
   } finally {
    try {
     if(rs != null) {
      rs.close();
      rs = null;
     }
     if(sta != null) {
      sta.close();
      sta = null;
     }
     if(conn != null) {
      conn.close();
      conn = null;
     }
    } catch (SQLException e1) {
     // TODO Auto-generated catch block
     e1.printStackTrace();
    }
   }
  
  //修改一条记录开始***************************************************
  } else if(e.getSource() == this.alButton) {
   //根据姓名来删除记录,没有就提示数据库没有
   String username = JOptionPane.showInputDialog("请输入您要修改的名字");
   //查询数据库
   String queSql = "select * from userTable where nameuser = '"+username+"'";
   
   //连接数据库
   try {
    Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
    conn = DriverManager.getConnection("jdbc:sqlserver://127.0.0.1:1433;DatabaseName=student", "sa", "sa");
    sta = conn.createStatement();
    //可以两次的执行同一个SQL语句
    rs = sta.executeQuery(queSql);
    //校验,如果数据库里没有此人,则弹框说明
    if(rs.next() == false) {
     JOptionPane.showMessageDialog(this, "查无此人,请核对后再次输入");
    }
    //从数据库取出数据放在表单上
    rs = sta.executeQuery(queSql);
     while(rs.next()) {
      
      this.naTextField.setText(rs.getString("nameuser"));
      this.passwordField.setText(rs.getString("userPassword"));
      this.passwordField2.setText(rs.getString("userPassword"));
      //性别
      if(rs.getString("userSex").equals("男")) {
       this.maRadioButton.setSelected(true);
      } else {
       this.feRadioButton.setSelected(true);
      }
      //爱好
      if(rs.getString("userEat").equals("吃饭")) {
       this.eaCheckBox.setSelected(true);
      }
      
      if(rs.getString("userSport").equals("运动")) {
       this.spCheckBox.setSelected(true);
      }
      if(rs.getString("userSleep").equals("睡觉")) {
       this.slCheckBox.setSelected(true);
      }
      //籍贯
      if(rs.getString("userAdress").equals("西安")) {
       this.comboBox.setSelectedItem("西安");
      } else if(rs.getString("userAdress").equals("北京")) {
       this.comboBox.setSelectedItem("北京");
      } else if(rs.getString("userAdress").equals("上海")) {
       this.comboBox.setSelectedItem("上海");
      } else if(rs.getString("userAdress").equals("广州")) {
       this.comboBox.setSelectedItem("广州");
      }
      //自我介绍
     
      this.textArea.setText(rs.getString("userShow"));
      JOptionPane.showMessageDialog(this, "每次修改完记录请提交表单");
     }
   } catch (ClassNotFoundException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
   } catch (SQLException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
   } finally {
    try {
     if(rs != null) {
      rs.close();
      rs = null;
     }
     if(sta != null) {
      sta.close();
      sta = null;
     }
     if(conn != null) {
      conn.close();
      conn = null;
     }
    } catch (SQLException e1) {
     // TODO Auto-generated catch block
     e1.printStackTrace();
    }
   }
   
  //查询一条记录开始***************************************************
  } else if(e.getSource() == this.quButton) {
   //根据姓名来删除记录,
   String username = JOptionPane.showInputDialog("请输入您要查询的名字");
   //查询数据库
   String queSql = "select * from userTable where nameuser = '"+username+"'";
   //连接数据库
   try {
    Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
    conn = DriverManager.getConnection("jdbc:sqlserver://127.0.0.1:1433;DatabaseName=student", "sa", "sa");
    sta = conn.createStatement();
    rs = sta.executeQuery(queSql);
    if(rs.next() == false) {
     JOptionPane.showMessageDialog(this, "查无此人,请核对后再次输入");
    }
    rs = sta.executeQuery(queSql);
    //从数据库中查出数据放在页面上
    while(rs.next()) {
     
     this.naTextField.setText(rs.getString("nameuser"));
     this.passwordField.setText(rs.getString("userPassword"));
     this.passwordField2.setText(rs.getString("userPassword"));
     //性别
     if(rs.getString("userSex").equals("男")) {
      this.maRadioButton.setSelected(true);
     } else {
      this.feRadioButton.setSelected(true);
     }
     //爱好
     if(rs.getString("userEat").equals("吃饭")) {
      this.eaCheckBox.setSelected(true);
     }
     
     if(rs.getString("userSport").equals("运动")) {
      this.spCheckBox.setSelected(true);
     }
     if(rs.getString("userSleep").equals("睡觉")) {
      this.slCheckBox.setSelected(true);
     }
     //籍贯
     if(rs.getString("userAdress").equals("西安")) {
      this.comboBox.setSelectedItem("西安");
     } else if(rs.getString("userAdress").equals("北京")) {
      this.comboBox.setSelectedItem("北京");
     } else if(rs.getString("userAdress").equals("上海")) {
      this.comboBox.setSelectedItem("上海");
     } else if(rs.getString("userAdress").equals("广州")) {
      this.comboBox.setSelectedItem("广州");
     }
     //自我介绍
    
     this.textArea.setText(rs.getString("userShow"));
     JOptionPane.showMessageDialog(this, "每次查询完记录请重置表单");
    }
   } catch (ClassNotFoundException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
   } catch (SQLException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
   } finally {
    try {
     if(rs != null) {
      rs.close();
      rs = null;
     }
     if(sta != null) {
      sta.close();
      sta = null;
     }
     if(conn != null) {
      conn.close();
      conn = null;
     }
    } catch (SQLException e1) {
     // TODO Auto-generated catch block
     e1.printStackTrace();
    }
   }
  //提交表单记录*******************************************************
   //思想先查数据库如果没有主键重复,直接新增一条,如果有先把主键相同的删除,然后把
   //修改后的一条记录插入到数据库里
  } else if(e.getSource() == this.suButton) {
   //获取姓名
   String username = this.naTextField.getText();
   //校验姓名
   if(username != null && username.length() <= 0) {
    JOptionPane.showMessageDialog(this, "用户名不能为空!", "提示框", JOptionPane.WARNING_MESSAGE);
    return;
   }
   //获取一次密码
   String password1 = String.valueOf(this.passwordField.getPassword());
   //获取二次密码
   String password2 = String.valueOf(this.passwordField2.getPassword());
   //校验密码
   if(password1 != null  && password1.length() <= 0 ) {
    JOptionPane.showMessageDialog(this, "密码不能为空");
    return;
   }
   if(password2 != null && password2.length() <= 0) {
    JOptionPane.showMessageDialog(this, "密码不能为空");
    return;
   }
   if(!(password1.equals(password2))) {
    JOptionPane.showMessageDialog(this, "两次密码不一致,请重新输入二次密码");
    return;
   }
   //获取性别
   String sex = null;
   if(this.maRadioButton.isSelected()) {
     sex = "男";
   } else {
    sex = "女";
   }
   //获取爱好
   String eat = null;
   if(this.eaCheckBox.isSelected()) {
    eat = "吃饭";
   }
   String sport = null;
   if(this.spCheckBox.isSelected()) {
    sport = "运动";
   }
   String sleep = null;
   if(this.slCheckBox.isSelected()) {
    sleep = "睡觉";
   }
   //获取户籍地
   String address = this.comboBox.getSelectedItem().toString();
   //获取自我介绍
   String showMe = this.textArea.getText();
   //拼接增加记录的Sql
   String addSql = "insert into userTable values('"+username+"', '"+password1+"', '"+sex+"',"
     + " '"+eat+"', '"+sport+"', '"+sleep+"',"
       + " '"+address+"', '"+showMe+"')";
   //检验数据库中是否已存在的主键相同的记录,如果有则不能插入
   String queSql = "select * from userTable where nameuser = '"+username+"'";
   
   //连接数据库
   try {
    Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
    conn = DriverManager.getConnection("jdbc:sqlserver://127.0.0.1:1433;DatabaseName=student", "sa", "sa");
    sta = conn.createStatement();
    //校验
    rs = sta.executeQuery(queSql);
    if(rs.next() == true) {
     JOptionPane.showMessageDialog(this, "数据库中已存在此人,不能重复插入");
     return;
    }
    int a = sta.executeUpdate(addSql);
    if(a > 0) {
     JOptionPane.showMessageDialog(this, "恭喜您,提交成功!");
    }
   } catch (ClassNotFoundException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
   } catch (SQLException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
   } finally {
    try {
     if(rs != null) {
      rs.close();
      rs = null;
     }
     if(sta != null) {
      sta.close();
      sta = null;
     }
     if(conn != null) {
      conn.close();
      conn = null;
     }
    } catch (SQLException e1) {
     // TODO Auto-generated catch block
     e1.printStackTrace();
    }
   }
   //清空表单内的数据
   this.naTextField.setText("");
   this.passwordField.setText("");
   this.passwordField2.setText("");
   //默认选择男生
   this.maRadioButton.setSelected(true);
   this.eaCheckBox.setSelected(false);
   this.spCheckBox.setSelected(false);
   this.slCheckBox.setSelected(false);
   this.comboBox.setSelectedItem("西安");
   this.textArea.setText("请在这里写你的自我介绍");
  //重置表单内容*******************************************************
  } else if(e.getSource() == this.reButton) {
   //清空表单内的数据
   this.naTextField.setText("");
   this.passwordField.setText("");
   this.passwordField2.setText("");
   //默认选择男生
   this.maRadioButton.setSelected(true);
   this.eaCheckBox.setSelected(false);
   this.spCheckBox.setSelected(false);
   this.slCheckBox.setSelected(false);
   this.comboBox.setSelectedItem("西安");
   this.textArea.setText("请在这里写你的自我介绍");
   
  }
  
 }
 
}

纯Java增删改查的更多相关文章

  1. Redis之java增删改查

    jedis是java的redis客户端实现,要使用jedis须要加入jedis的maven依赖: <dependency> <groupId>redis.clients< ...

  2. JAVA增删改查XML文件

    最近总是需要进行xml的相关操作. 不免的要进行xml的读取修改等,于是上网搜索,加上自己的小改动,整合了下xml的常用操作. 读取XML配置文件 首先我们需要通过DocumentBuilderFac ...

  3. JAVA 增删改查接口命名规范(dao层与 service 层

    开发时,有很多规范,这里写的是命名规范. Dao 接口命名   insert batchInsert selectOne selectById count selectList update dele ...

  4. Java对XML文档的增删改查

    JAVA增删改查XML文件   最近总是需要进行xml的相关操作. 不免的要进行xml的读取修改等,于是上网搜索,加上自己的小改动,整合了下xml的常用操作. 读取XML配置文件 首先我们需要通过Do ...

  5. node 后台使用增删改查(4)

    无论node还是java增删改查都是一样的原理,变得是配合框架使用时候有简便方法而已. 这里我接着上一篇开始讲,使用同一个数据库(数据库创建)这里必须创建了数据库 优化:为了维护方便这里我们把sql语 ...

  6. 纯Java JDBC连接数据库,且用JDBC实现增删改查的功能

    Java JDBC连接数据库 package cn.cqvie.yjq; import java.sql.*; /** * 注册数据库的驱动程序,并得到数据库的连接对象 * @author yu * ...

  7. mongoDB 学习笔记纯干货(mongoose、增删改查、聚合、索引、连接、备份与恢复、监控等等)

    最后更新时间:2017-07-13 11:10:49 原始文章链接:http://www.lovebxm.com/2017/07/13/mongodb_primer/ MongoDB - 简介 官网: ...

  8. Java通过JDBC进行简单的增删改查(以MySQL为例)

    Java通过JDBC进行简单的增删改查(以MySQL为例) 目录: 前言:什么是JDBC 一.准备工作(一):MySQL安装配置和基础学习 二.准备工作(二):下载数据库对应的jar包并导入 三.JD ...

  9. 通过Java代码实现对数据库的数据进行操作:增删改查

    在写代码之前,依然是引用mysql数据库的jar包文件:右键项目-构建路径-设置构建路径-库-添加外部JAR 在数据库中我们已经建立好一个表xs :分别有xuehao  xingming    xue ...

随机推荐

  1. vue.js安装问题

    1.安装:npm install --global vue-cli 2.创建项目:vue init webpack my-project npm WARN deprecated browserslis ...

  2. EOS 开发终极神器-vscode (你绝对找不到的干货)

    https://eosfans.io/topics/323 前言:最近一直苦于EOS开发没有好用的IDE,用了很多,试了很多,都让人觉得有些差强人意.于是乎笔者在经过,长时间的查找实践中,终于找到了e ...

  3. H5缩放效果的问题和缓存问题

    https://segmentfault.com/q/1010000000305316 http://blog.csdn.net/hudashi/article/details/50963585 四. ...

  4. xcode 定义自己的代码片段

    个人修改后的github地址:https://github.com/jiangys/xcode_tool 电脑xcode存放的路径:~/Library/Developer/Xcode/UserData ...

  5. vue中使用echarts

    1.下载依赖 cnpm i echarts -S 2.模块中引入 <template> <div class="analyzeSystem"> <di ...

  6. 漏洞复现:Struts2 S2-032 漏洞环境

    Struts2 S2-032 漏洞环境 http://vulapps.evalbug.com/s_struts2_s2-032/ POC: http://127.0.0.1/memoindex.act ...

  7. HDU 2604 Queuing(递推+矩阵)

    Queuing [题目链接]Queuing [题目类型]递推+矩阵 &题解: 这题想是早就想出来了,就坑在初始化那块,只把要用的初始化了没有把其他的赋值为0,调了3,4个小时 = = 本题是可 ...

  8. Mongo数据两表关联创建视图示例

    表tblCard: {"cNo":"11","oRDate":ISODate("2017-08-01T00:00:00.000+0 ...

  9. 数据库所有者 (dbo)

    数据库所有者 (dbo) dbo 是具有在数据库中执行所有活动的暗示性权限的用户.将固定服务器角色 sysadmin 的任何成员都映射到每个数据库内称为 dbo 的一个特殊用户上.另外,由固定服务器角 ...

  10. 关于python中selector问题

    在做大型的爬虫时,re表达式往往效率不高,scrapy框架为爬虫提供了很好的爬虫方法 scrapy提取数据时有一套自己的机制,即selectors,一般通过特定的XPath,或者特定 的CSS表达式来 ...