当前位置:网站首页>Preparedstatement principle of preventing SQL injection
Preparedstatement principle of preventing SQL injection
2022-06-25 03:46:00 【Stupid in the food】
1. PreparedStatement And Statement What is it for ?
PreparedStatement and Statement All right sql Statement and returns the compiled identifier .
2. PreparedStatement The advantages of ?
1. Effectively prevent sql Inject .
2. precompile , Than statement High execution efficiency ( Compile multiple times at a time )
3. Good readability of parameter settings .
3. What is? sql Inject ?
The user enters malicious in the front page sql sentence , Cheat the server to execute malicious sql Code , Cause database leakage , This is it. sql Inject . for example :
select * from user where name = ‘${name}’
If the parameter Zhang San is passed in ’ or 1=’1, The user can get all the data without knowing the name .
4. PrepareStatement How to prevent sql Injected ?
PrepareStatement Each character of the parameter will be traversed , Line break found 、 quotes 、 Special characters such as slashes , Will be escaped . Above after escape sql Injection will fail .
Before escape :select * from user where name = ‘ Zhang San ’ or 1=’1’;
After escaping : select * from user where name = ‘ Zhang San \’ or 1 = \’1’;
obviously , After the escape sql Statement query result is null . Unless there is a wonderful flower named “ Zhang San ’ or 1 = ’1”.
reference : prevent sql Principle of injection
边栏推荐
- 同花顺证券开户是安全的吗?
- 网上开户股票安全吗?怎么开户呢?
- Easynvr fails to use onvif to detect the device. What is the reason why "no data" is displayed?
- Introduction to database system
- Wuenda, the new course of machine learning is coming again! Free auditing, Xiaobai friendly
- XML modeling
- MySQL根据表前缀批量修改、删除表
- Tencent's open source project "Yinglong" has become a top-level project of Apache: the former long-term service wechat payment can hold a million billion level of data stream processing
- redis
- 力扣每日一题-第26天-506.相对名次
猜你喜欢
可能是拿反了的原因
程序猿职业发展9项必备软技能
谷歌创始人布林二婚破裂:被曝1月已提出与华裔妻子离婚,目前身家6314亿美元...
Why can banana be a random number generator? Because it is the "king of radiation" in the fruit industry
ICML 2022 | ByteDance AI Lab proposes a multimodal model: x-vlm, learning multi granularity alignment of vision and language
zabbix的安装避坑指南
CVPR大会现场纪念孙剑博士,最佳学生论文授予同济阿里,李飞飞获黄煦涛纪念奖...
马斯克被诉传销索赔2580亿美元,台积电公布2nm制程,中科院发现月壤中含有羟基形式的水,今日更多大新闻在此...
Randla net: efficient semantic segmentation of large scale point clouds
吴恩达机器学习新课程又来了!旁听免费,小白友好
随机推荐
Collaboration + Security + storage, cloud box helps Shenzhen edetai restructure its data center
The era of copilot free is over! The official version is 67 yuan / month, and the student party and the defenders of popular open source projects can prostitute for nothing
The more AI evolves, the more it resembles the human brain! Meta found the "prefrontal cortex" of the machine. AI scholars and neuroscientists were surprised
How to choose a securities company when opening an account with a compass? Which is safer
js工具函数,自己封装一个节流函数
股票在网上开户安全吗?在线等答案
MCN institutions are blooming everywhere: bloggers and authors should sign contracts carefully, and the industry is very deep
俄罗斯AIRI研究院等 | SEMA:利用深度迁移学习进行抗原B细胞构象表征预测
完美洗牌问题
Tensorflow, danger! Google itself is the one who abandoned it
Lu Qi invests in quantum computing for the first time
There is the word "Internet" in the concept of industrial Internet, but it is an existence that is not related to the Internet
The sign in function completes 03 "IVX low code sign in system production"
Why can banana be a random number generator? Because it is the "king of radiation" in the fruit industry
MySQL根据表前缀批量修改、删除表
MySQL installation tutorial
Peking University has a new president! Gongqihuang, academician of the Chinese Academy of Sciences, took over and was admitted to the Physics Department of Peking University at the age of 15
How to raise key issues in the big talk club?
Winxp kernel driver debugging
How can novices of cross-border e-commerce prevent store association? What tool is good?