当前位置:网站首页>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); } } }
边栏推荐
- 2022 low voltage electrician examination and low voltage electrician simulation examination question bank
- Qt6 QML Book/Qt Quick 3D/基础知识
- Producer consumer mode (multithreading, use of shared resources)
- XAI+网络安全?布兰登大学等最新《可解释人工智能在网络安全应用》综述,33页pdf阐述其现状、挑战、开放问题和未来方向
- University of Electronic Science and technology | playback of clustering experience effectively used in reinforcement learning
- Instructions for common methods of regular expressions
- From the behind the scenes arena of the ice and snow event, see how digital builders can ensure large-scale events
- In 2021, the global revenue of thick film resistors was about $1537.3 million, and it is expected to reach $2118.7 million in 2028
- The 12th Blue Bridge Cup
- JMeter plug-in installation
猜你喜欢

Research Report on the overall scale, major manufacturers, major regions, products and application segmentation of rotary tablet presses in the global market in 2022

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

强基计划 数学相关书籍 推荐

Task of gradle learning

APEC industry +: father of the king of the ox mill, industrial Internet "king of the ox mill anti-wear faction" Valentine's Day greetings | Asia Pacific Economic media | ChinaBrand

Haven't expressed the artifact yet? Valentine's Day is coming. Please send her a special gift~

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

MySQL master-slave synchronization principle

LabVIEW training

jvm jni 及 pvm pybind11 大批量数据传输及优化
随机推荐
Nmap and masscan have their own advantages and disadvantages. The basic commands are often mixed to increase output
jvm jni 及 pvm pybind11 大批量数据传输及优化
Discussion Net legacy application transformation
What is the maximum number of concurrent TCP connections for a server? 65535?
[Yugong series] February 2022 Net architecture class 004 ABP vNext used in WPF project
Install and use Chrony, and then build your own time server
Haven't expressed the artifact yet? Valentine's Day is coming. Please send her a special gift~
2022 high voltage electrician examination and high voltage electrician reexamination examination
JMeter plug-in installation
MySQL learning notes - single table query
Software testing skills, JMeter stress testing tutorial, obtaining post request data in x-www-form-urlencoded format (24)
Qtablewidget control of QT
如临现场的视觉感染力,NBA决赛直播还能这样看?
In 2021, the global general crop protection revenue was about $52750 million, and it is expected to reach $64730 million in 2028
Apprentissage intensif - notes d'apprentissage 1 | concepts de base
[Yugong series] go teaching course 002 go language environment installation in July 2022
University of Electronic Science and technology | playback of clustering experience effectively used in reinforcement learning
Test changes in Devops mode -- learning and thinking
Instructions for common methods of regular expressions
Research Report on the overall scale, major manufacturers, major regions, products and application segmentation of rotary tablet presses in the global market in 2022