- 博客(135)
- 收藏
- 关注
原创 2021-08-22 过滤器实现登录权限拦截
登录页面<%@ page contentType="text/html;charset=UTF-8" language="java" %><html><head> <title>登录</title></head><body><form action="/servlet/login" method="post"> <input type="text" name="usernam.
2021-08-22 20:43:21 328
原创 2021-08-22 初识过滤器
首先导入包 <!-- 连接数据库 --> <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId&g
2021-08-22 17:19:31 134
原创 2021-08-21 初识javabean
先写一个类package com.pangiggs.pojo;public class people { private int id; private String name; private int age; private String address; public people() { } public people(int id, String name, int age, String address) { ..
2021-08-21 22:00:55 92
原创 2021-08-20 JSP JSTL标签
jstl核心标签:<%@ page contentType="text/html;charset=UTF-8" language="java" %><%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%--引入jstl标签--%><html><head> <title>Title</title></head>&l
2021-08-21 00:43:45 89
原创 2021-08-19 定制错误页面,共用页面设置
XML配置<?xml version="1.0" encoding="UTF-8"?><web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/..
2021-08-19 23:07:02 65
原创 2021-08-19初识JSP
<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/mav
2021-08-19 22:48:36 89
原创 2021-08-18 Session详解
public class SessionDemo01 extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { req.setCharacterEncoding("utf-8"); resp.setCharacterEncoding(...
2021-08-18 22:21:39 114
原创 2021-08-17Cookie 详解
//保存用户上一次访问的时间public class CookieDemo01 extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { //服务器告诉你,你来的时间,封装为一个信件,你下次带来就知道你来过了 req.setChar..
2021-08-17 22:47:17 96
原创 2021-08-17 Request 重定向转发以及其他应用
public class LoginServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { req.setCharacterEncoding("utf-8"); resp.setCharacterEncoding("u.
2021-08-17 00:45:25 104
原创 2021-08-16Response 重定向使用
public class RequetTest extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { System.out.println("进入请求中"); //测试用 //处理请求 String username.
2021-08-16 21:36:53 111
原创 2021-08-15 reponse文件下载路径
web下载文件设置的头信息转:https://www.cnblogs.com/hackxiyu/p/9046247.html使用web下载文件的时候,需要在实例化FileServlet 类的doGet方法里面添加以下设置resp.setHeader(“Content-disposition”,“attachment;filename”+ URLEncoder.encode(filename,“UTF-8”));主要代码:import javax.servlet.ServletException;
2021-08-15 22:25:01 91
原创 2021-08-15 Servlet Properties 读取资源
读取资源文件import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import java.io.IOException;import java.io.InputStream;import java.util.Prop.
2021-08-15 17:03:58 106
原创 2021-08-13 初识servlet
修改web.xml<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http:
2021-08-13 23:01:07 93
原创 2021-08-12初识maven
<!--在build中配置resources,来防止我们资源导出失败的问题--> <build> <resources> <resource> <directory>src/main/resources</directory> <excludes> <exclude&.
2021-08-12 22:25:43 72
原创 2021-08-10 C3P0连接池
配置资源文件<?xml version="1.0" encoding="UTF-8"?> <c3p0-config> <!-- c3p0的缺省(默认)配置 如果在代码中ComboPooledDataSource ds=new ComboPooledDataSource();这样写就表示使用的是c3p0的缺省(默认)--> <default-config> <.
2021-08-10 23:39:29 95
原创 2021-08-10 idea 事务的操作
创建数据库表CREATE TABLE account( id Int PRIMARY KEY AUTO_INCREMENT, NAME VARCHAR(40), money FLOAT);/*插入测试数据*/insert into account(name,money) values('A',1000);insert into account(name.
2021-08-10 22:35:01 481
原创 PreparedStatement防止SQL注入
插入数据import com.pan.lesson01.lesson02.utils.JdbcUtils;import java.sql.*;import java.util.Date;public class TestInsert { public static void main(String[] args) throws SQLException { Connection conn = null; PreparedStatement pstm = n
2021-08-10 21:23:00 79
原创 2021-08-09 idea -- Mysql 增删改查
封装工具类import java.io.IOException;import java.io.InputStream;import java.sql.*;import java.util.Properties;import com.mysql.jdbc.Connection;public class JdbcUtils { private static String driver = null; private static String url = null; ..
2021-08-10 00:16:48 125
原创 2021-08-08 idea 连接Mysql
import java.sql.*;//我的第一个jdbc程序public class jdbc01demo { public static void main(String[] args) throws ClassNotFoundException, SQLException { //加载驱动 Class.forName("com.mysql.jdbc.Driver"); //固定写法 //连接信息 String url =.
2021-08-08 22:59:22 173 1
原创 2021-08-08三大范式与JDBC
![在这里插入图片描述](https://img-blog.csdnimg.cn/95d6710070784d60a0ec1b91becf7b19.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3BhbmdpZ2dz,size_16,color_FFFFFF,t_70包java.sqljavax.sql还需要导入数据库驱动包..
2021-08-08 22:22:28 59
原创 2021-08-08
-- 创建用户CREATE USER pangiggs IDENTIFIED BY '123456'-- 修改当前密码SET PASSWORD = PASSWORD '123456'-- 修改指定用户密码SET PASSWORD FOR pangiggs = PASSWORD ('123456')-- 重命名用户RENAME USER pangiggs TO panpan-- 授予全部权限GRANT ALL PRIVILEGES ON *.* TO panpan-- 查看权限
2021-08-08 17:06:17 60
原创 2021-08-08索引在小数据量的时候用处不大,但在大数据的时候十分明显
SET GLOBAL log_bin_trust_function_creators=TRUE;DELIMITER $$ -- 函数,必须写-- 写函数之前必须要写,标志CREATE FUNCTION mock_data () -- 创建函数RETURNS INTBEGINDECLARE num INT DEFAULT 1000000;DECLARE i INT DEFAULT 0;WHILE i<num DOINSERT INTO `app_user`(`name`,`ema.
2021-08-08 16:35:17 144
原创 2021-08-08 mysql索引
– 显示所有的索引SHOW INDEX FROM student– 增加索引ALTER TABLE student ADD FULLTEXT studentname(studentname)– 分析sql语句执行状况EXPLAIN SELECT * FROM student;EXPLAIN SELECT * FROM student WHERE MATCH(studentname) AGAINST(‘李’) – 使用全文索引 真正使用不需要EXPLAIN...
2021-08-08 15:16:52 94
原创 2021-08-08 事务的提交,回滚
SET autocommit = 0 -- 关闭自动提交事务 暂时不要执行-- 事务开启START TRANSACTION -- 之后的都在同一个事务内-- 提交COMMIT-- 回滚ROLLBACK-- 事务结束SET autocommit = 1 -- 开启事务自动提交SAVEPOINT -- 保存点 暂存ROLLBACK TO SAVEPOINT -- 回滚到保存点RELEASE SAVEPOINT -- 删除保存点-- =======模拟场景 转账====.
2021-08-08 00:28:19 65
原创 2021-08-06 MD5mysql 加密校验
-- =============== 测试md5 加密 =======================CREATE TABLE `testmd5`(`id` INT(4) NOT NULL,`name` VARCHAR(20) NOT NULL,`pdw` VARCHAR(50) NOT NULL,PRIMARY KEY(`id`))ENGINE=INNODB DEFAULT CHARSET=utf8-- 明文密码INSERT INTO testmd5 VALUES(1,'张三','12
2021-08-06 21:51:08 126
原创 2021-08-06聚合函数,分组过滤
-- 查询不同课程的平均分,最高分,最低分,平均分大于80的-- 核心:根据不同的课程分组SELECT subjectname ,AVG(studentresult) AS 平均分,MAX(studentresult) AS 最高分,MIN(studentresult) AS 最低分FROM `result` rINNER JOIN `subject` subON r.`subjectno` = sub.`subjectno`GROUP BY r.`subjectno` -- 通过什么来分.
2021-08-06 21:26:25 72
原创 mysql常用函数
-- =========================常用函数==============================-- 数学运算SELECT ABS(-8) -- 绝对值SELECT CEILING(9.4) -- 向上取整数SELECT FLOOR(9.4) -- 向下取整数SELECT RAND() -- 随机数SELECT SIGN(-100) -- 判断数的符号 -- 字符串 SELECT CHAR_LENGTH('难不难哟') -- 长度SELECT CONC
2021-08-06 20:56:02 68
原创 2021-08-05查询排序分页语句
-- ========================分页limit和排序order by================================SELECT s.`studentno`,`studentname`,`subjectname`,`studentresult`FROM `student` sINNER JOIN `result` rON s.studentno = r.studentnoINNER JOIN `subject` subON r.`subjectno` ..
2021-08-05 22:12:59 67
原创 2021-08-04 Mysql自连接
-- ================自连接:自己的表和自己的连接,核心是-一张表拆为两张一样的表=====================CREATE TABLE category ( categoryid INT(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主题ID', pid INT(10) NOT NULL COMMENT '父ID', categoryName VARCHAR(50) NOT NULL COMMENT '主题名字', .
2021-08-04 22:32:34 65
原创 2021-08-04 Mysql联表查询
-- ==================联表查询join=======================-- 查询参加了考试的同学(学号 姓名 科目编号 分数)SELECT * FROM `student`SELECT * FROM `result`SELECT s.studentno,studentname,subjectno,studentresultFROM `student` AS sINNER JOIN `result` AS rWHERE s.studentno = ...
2021-08-04 21:36:46 73
原创 2021-08-04 模糊查询
-- ==========================模糊查询=====================-- 查询姓刘的同学 like结合 %(代表0到任意字符) _(代表一个字符)SELECT studentno,`studentname` FROM `student`WHERE studentname LIKE '王%'-- 查询姓李的同学,名字后面只有一个字的SELECT studentno,`studentname` FROM `student`WHERE studentn..
2021-08-04 01:00:20 101
原创 2021-08-04 WHERE条件查询
SELECT studentno,`studentresult` FROM result-- 查询考试成绩95-100分之间的SELECT studentno,`studentresult` FROM resultWHERE studentresult>=95 AND studentresult<=100-- 除了1000号学生之外的同学的成绩SELECT studentno,`studentresult` FROM resultWHERE studentno!=1000;..
2021-08-04 00:29:24 68
原创 2021-08-03 DISTINCT去重复操作
-- 查询一下有哪些同学参加了考试SELECT * FROM resultSELECT `studentno` FROM result-- 重复数据去重SELECT DISTINCT `studentno` FROM result-- 学员考试成绩加1分SELECT `studentno`,`studentresult`+1 AS '提分后' FROM result...
2021-08-03 22:36:15 92
原创 2021-08-03 SELECT简单查询
-- 查询全部的学生SELECT * FROM studentSELECT * FROM result-- 查询指定字段SELECT `studentno`, `studentname` FROM student-- 使用别名 ASSELECT `studentno` AS 学号, `studentname` AS 学生姓名 FROM student AS 学生表-- 函数 Concat(a,b) 拼接字段SELECT CONCAT('姓名: ',studentname) AS 新名字
2021-08-03 00:17:10 77
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人