当前位置:网站首页>MySQL——SQL注入问题
MySQL——SQL注入问题
2022-07-03 21:02:00 【Java学不会】
1、SQL注入问题
- SQL存在漏洞,会被攻击导致数据泄露
2、PreparedStatement对象
PreparedStatement 可以防止SQL注入,效率更好
package demo; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; import java.util.Date; public class TestInsert01 { public static void main( String[] args ) { Connection conn = null; PreparedStatement st= null; try { conn=JdbcUtils.getConnection(); //使用? 占位符代替参数 String sql ="INSERT\tINTO users(`id`,`NAME`,`PASSWORD`,`email`,`birthday`) VALUES(?,?,?,?,?)"; st = conn.prepareStatement(sql); //手动给参数赋值 st.setInt(1,5); st.setString(2,"Java学不会"); st.setString(3,"123456"); st.setString(4,"[email protected]"); st.setDate(5,new java.sql.Date(new Date().getTime())); //执行 int i = st.executeUpdate(); if(i>0){ System.out.println("插入成功!"); } } catch (SQLException e) { e.printStackTrace(); }finally { JdbcUtils.release(conn,st,null); } } }
边栏推荐
- Use nodejs+express+mongodb to complete the data persistence project (with modified source code)
- Wargames study notes -- Leviathan
- Leetcode daily question 540 A single element in an ordered array Valentine's Day special article looking for a single dog in a pile of lovers ~ the clown is myself
- Basic preprocessing and data enhancement of image data
- Gauss elimination solves linear equations (floating-point Gauss elimination template)
- leetcode-540. A single element in an ordered array
- [secretly kill little buddy pytorch20 days -day02- example of image data modeling process]
- Sort out several network request methods of JS -- get rid of callback hell
- 2022 high voltage electrician examination and high voltage electrician reexamination examination
- Fingerprint password lock based on Hal Library
猜你喜欢

JS three families
![Measurement fitting based on Halcon learning -- Practice [1]](/img/71/9f6c27aa89035b2550bdb0ac902045.jpg)
Measurement fitting based on Halcon learning -- Practice [1]

(5) Web security | penetration testing | network security operating system database third-party security, with basic use of nmap and masscan

Apprentissage intensif - notes d'apprentissage 1 | concepts de base

Go learning notes (4) basic types and statements (3)

Hcie security Day10: six experiments to understand VRRP and reliability

Basic preprocessing and data enhancement of image data

Use nodejs+express+mongodb to complete the data persistence project (with modified source code)

强化学习-学习笔记1 | 基础概念

Visiontransformer (I) -- embedded patched and word embedded
随机推荐
Rhcsa third day notes
Transformer structure analysis and the principle of blocks in it
Link aggregation based on team mechanism
Such as the visual appeal of the live broadcast of NBA Finals, can you still see it like this?
The 12th Blue Bridge Cup
Haven't expressed the artifact yet? Valentine's Day is coming. Please send her a special gift~
6006. Take out the minimum number of magic beans
【愚公系列】2022年7月 Go教学课程 002-Go语言环境安装
Shortest path problem of graph theory (acwing template)
@Scenario of transactional annotation invalidation
你真的知道自己多大了吗?
Read the root directory of the folder, write txt and generate random samples
Test changes in Devops mode -- learning and thinking
Cap and base theory
2166. Design bit set
Fingerprint password lock based on Hal Library
Use nodejs+express+mongodb to complete the data persistence project (with modified source code)
Talk about daily newspaper design - how to write a daily newspaper and what is the use of a daily newspaper?
Mysql database ----- common commands of database (based on database)
[gd32l233c-start] 5. FLASH read / write - use internal flash to store data