• 复利计算器6.0


      对界面进行了升级添加了用户注册于登录界面,更完善的功能待续。。。。

    主要代码:

     1 package DataBase;
     2 
     3 import java.sql.Connection;
     4 import java.sql.ResultSet;
     5 import java.sql.SQLException;
     6 import java.sql.Statement;
     7 
     8 public class SingUpConnect {
     9     private Connection connection;
    10     private Statement statement;
    11     ResultSet resultSet;
    12     private String name;
    13     private String password;
    14     public String getName() {
    15         return name;
    16     }
    17     public void setName(String name) {
    18         this.name = name;
    19     }
    20     public String getPassword() {
    21         return password;
    22     }
    23     public void setPassword(String password) {
    24         this.password = password;
    25     }
    26     public SingUpConnect() {
    27         connection=ConnectionFactory.getInstane().makeConnection();
    28     }
    29     public void Sin_In() {
    30         ResultSet resultSet=null;
    31         String sql="SELECT * FROM user";
    32         try {
    33             statement=connection.createStatement();
    34         } catch (SQLException e) {
    35             
    36             e.printStackTrace();
    37         }
    38         try {
    39             resultSet=statement.executeQuery(sql);
    40             while (resultSet.next()) {
    41                 name=resultSet.getString("name");
    42                 password=resultSet.getString("password");
    43             }
    44         } catch (SQLException e) {
    45             
    46             e.printStackTrace();
    47         }
    48         try {
    49             while (resultSet.next()) {
    50                 System.out.println(resultSet.getString("username"));
    51                 System.out.println(resultSet.getString("password"));
    52             }
    53         } catch (SQLException e) {
    54             
    55             e.printStackTrace();
    56         }
    57         finally{
    58             try {
    59                 resultSet.close();
    60             } catch (Exception e2) {
    61                 
    62             }
    63             try {
    64                 statement.close();
    65             } catch (Exception e2) {
    66                 
    67             }
    68             try {
    69                 connection.close();
    70             } catch (Exception e2) {
    71             
    72             }
    73         }
    74         
    75     }
    76     public void SinUp(String name,String password){
    77         try {
    78             connection.setAutoCommit(false);
    79             UserDao userDao=new UserDaoImpl();
    80             User user=new User();
    81             user.setName(name);
    82             user.setPassword(password);
    83             userDao.save(connection, user);
    84             connection.commit();
    85         } catch (Exception e) {
    86             try {
    87                 connection.rollback();
    88             } catch (Exception e2) {
    89                 e2.printStackTrace();
    90             }
    91         }
    92     }
    93 }

  • 相关阅读:
    参考教程 python 手动搭建ANN,并进行具体实现
    ubuntu18.04 ssh 问题
    Ubuntu18.04 启动后进不了界面 [ failed command: READ DMA ]
    Emacs 使用 markdown 模式
    linux 下 Emacs dired 模式 隐藏 dot file ".filename" 文件
    Ubuntu 16.04 安装后(使用旧的用户目录)登陆不进去
    AWS-SS配置过程
    Jupyter-notebook 导出时不显示Input[]代码
    [网络流24题] 方格取数问题 (最大权独立集---网络最小割)
    [网络流24题] 最长递增子序列 (最多不相交路径---网络最大流)
  • 原文地址:https://www.cnblogs.com/LwF39/p/5393377.html
Copyright © 2020-2023  润新知