cgb2107-第二阶段-day06-jdbc优化

需求: 模拟用户登录现象

  1. 需要你自己创建user表,并提供一些字段(id name password)
  2. 向表总添加记录,如1 Jack 123456
  3. 编写 jdbc程序,完成登录
  4. 本质上就是向sql发起了select语句
    select * from user where name = ‘jack’ and password = '‘123456’
    5.当用户输入正确的用户名和密码时,提示登录成功,否则提示登录失败

-2 测试

package zhu.jdbc;

import java.sql.*;
import java.util.Scanner;

/**
 * @作者: 朱学长
 * @时间: 2021/9/1 0001 星期三 22:00
 */
public class java2 {
    public static void main(String[] args)  {
        method();
    }

    private static void method() {
        Connection conn = null;
        PreparedStatement ps = null;
        ResultSet rs = null;

        try{
            System.out.println("please input your username:");
            String user = new Scanner(System.in).nextLine();
            String pwd = new Scanner(System.in).nextLine();
            String sql = "select * from user where name = ? and password = ?";
            ps = getConnection().prepareStatement(sql);
            ps.setString(1,user);
            ps.setString(2,pwd);

            rs = ps.executeQuery();
            if(rs.next()){
                System.out.println("you had sign in successfully");
            }else{
                System.out.println("sign in false");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }finally {

            ifclose(rs,ps,conn);
        }
    }
    public static void ifclose(ResultSet rs,PreparedStatement ps,Connection conn){
        if(rs != null){
            try {
                rs.close();
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }
        }
        if(ps != null){
            try {
                ps.close();
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }
        }
        if (conn != null){
            try {
                conn.close();
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }
        }
    }

    private static Connection getConnection() throws Exception {
        Class.forName("com.mysql.jdbc.Driver");
        String url = "jdbc:mysql://localhost:3306/cgb2022";
        String username = "root";
        String password = "123456";
        Connection conn = DriverManager.getConnection(url,username,password);
        return conn;
    }
}

二.html

1. 概述

是超文本标记语言,用来完成一个静态网页
结构:
由大量的标签组成的.
标签都是成对出现的

-2入门案例

<!DOCTYPE html> <!--文档声明-->
<html>  <!--根元素,标记这是一个网页文件-->
	<head> <!--头文件-->
 		<meta charset="utf-8"> <!--设置了编码-->
		<title></title>  <!--设置了标题-->
	</head>
	<body>  <!--体部分,指定网页内容-->

<img src="C:\Users\Administrator\Desktop\1.png" 
		 border="10px"
		 width="50%"
		 height="30%s"
		 >

<h1 align="center">alibaba</h1>
		<h2>baidu</h2>
		<h3>tencent</h3>
		<h4>meitaun</h4>
		<h5>yahoo</h5>
		<h6>google</h6>
		hello!\&lt; <br> \&gt;  \&gt;\&gt;\&gt;
		hel   lo
		hel &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;lo
		<br><br /> <!--自闭标签-->
		<h1 align="absbottom">英雄回家</h1>
		<h2>阿富汗</h2>
		<h3>csdn</h3>
		<h4>ahhH</h4>
		<h5>BAIDU</h5>
		<h6>ALIBABA</h6>
	</body>
</html>

-3 练习

标题标签

# 三.GIT
 ## -1 .概述
 是一个开源的分布式的版本控制产品
 可以上传开源项目,上传到gitee服务器上,很方便的管理代码,还可以下载

上传: 
工作空间:用来保存资源的一个文件夹
本地索引:给即将上传的资源,设置索引,提高传输效率
本地仓库: 是指在Gitee的服务器里,创建一个文件夹,保存了你要提交的资源

下载: 
只从远程仓库下载资源到自己的电脑里

## -2 常见命令
add: 从工作空间把要上传的资源 添加到本地索引
commit: 从本地索引提交到本地仓库
push : 从本地仓库把资源推送到 远程仓库
clone/pull:从远程仓库到本地
## -3安装
见官网
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值