当前位置:网站首页>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); } } }
边栏推荐
- SQL injection - Fundamentals of SQL database operation
- Plan for the first half of 2022 -- pass the PMP Exam
- Task of gradle learning
- Etcd 基于Raft的一致性保证
- Rhcsa third day operation
- The 12th Blue Bridge Cup
- Basic knowledge of dictionaries and collections
- Hcie security Day12: supplement the concept of packet filtering and security policy
- CesiumJS 2022^ 源码解读[7] - 3DTiles 的请求、加载处理流程解析
- 【c】 Digital bomb
猜你喜欢

2022 melting welding and thermal cutting examination materials and free melting welding and thermal cutting examination questions

Basic preprocessing and data enhancement of image data

SQL injection - Fundamentals of SQL database operation

9 pyqt5 qscrollarea scroll area and qscrollbar scroll bar

Task of gradle learning

Visiontransformer (I) -- embedded patched and word embedded

Qtablewidget control of QT

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

Link aggregation based on team mechanism

Reinforcement learning - learning notes 1 | basic concepts
随机推荐
leetcode-540. A single element in an ordered array
Mysql database ----- common commands of database (based on database)
Example of peanut shell inner net penetration
Cannot load driver class: com. mysql. cj. jdbc. Driver
App compliance
MDM mass data synchronization test verification
How can the outside world get values when using nodejs to link MySQL
Battle drag method 1: moderately optimistic, build self-confidence (1)
TLS environment construction and plaintext analysis
The "boss management manual" that is wildly spread all over the network (turn)
Basic knowledge of dictionaries and collections
Set, weakset, map, weakmap in ES6
How to modify the network IP addresses of mobile phones and computers?
The 12th Blue Bridge Cup
Such as the visual appeal of the live broadcast of NBA Finals, can you still see it like this?
Apprentissage intensif - notes d'apprentissage 1 | concepts de base
Custom view incomplete to be continued
Redis data migration (II)
Link aggregation based on team mechanism
全网都在疯传的《老板管理手册》(转)