当前位置:网站首页>The difference between statement and Preparedstatement and how to use placeholders
The difference between statement and Preparedstatement and how to use placeholders
2022-07-24 04:54:00 【lzhNox】
Statement and PreparedStatement The difference between
First of all, let's talk about the connection between the two :
- PreparedStatement Inherited from Statement
- PreparedStatement And Statement It's all interfaces
Then there is the difference between the two :
- PreaparedStatement It will be precompiled , and Statement Will not precompile
So when we operate , Sometimes I will consider which one to use .
First, let's make it clear ,PreparedStatement The object cost of is higher than Statement Big , however , It will precompile , in other words , The next time you use this object , Will not compile again , This saves compilation time , and Statement There will be no precompiling
therefore , When we need batch processing , Just use PreparedStatement, also PreparedStatement Supports the use of placeholders
When we only need one-time access Statement.
Here we extend the use of placeholders
String sql = ("insert into student values(?,?)");/ Use it here ? Instead of characters
PreparedStatement preparedStatement = connection.prepareStatement(sql);
When we need to use placeholders :
preparedStatement.setInt(1,6);
preparedStatement.setString(2, Zhang San );
Be careful , here student The column names of the tables are :id int,name varchar(20)
We use set when , The first parameter is from 1 Start writing , The second parameter is the content of the placeholder
For example, the above code , Inserted in table id:6 name: Zhang San A line
边栏推荐
- PSO and mfpso
- Ben, reducing online importance is the same. Abnormal instance CP operation found
- Learn more about the new features of ES6 in grain mall of e-commerce project
- Xiaohongshu joins hands with HMS core to enjoy HD vision and grow grass for a better life
- How is it that desktop icons can't be dragged? Introduction to the solution to the phenomenon that desktop file icons can't be dragged
- yum 查看某个命令由哪个安装包提供
- How to register and apply for free for Apple Developer account in order to enjoy the upgrade experience at the first time
- Chapter 7 other neural network types
- How long has it been since you changed your cell phone?
- Chapter 1 regression, classification & clustering
猜你喜欢
![Rlib learning - [4] - algorithmconfig detailed introduction [pytoch version]](/img/1e/95078ad64a17686463547e8ba87cb1.png)
Rlib learning - [4] - algorithmconfig detailed introduction [pytoch version]

Threejs+shader drawing commonly used graphics

Esp32:arduino tutorial summary

Chapter VI more supervision training

How can e-commerce projects solve the over issuance of online coupons (troubleshooting + Solutions) (glory Collection)

The second chapter is encog's data acquisition

Kingbase V8R6集群安装部署案例---脚本在线一键缩容

uniapp学习

"Paper reproduction" bidaf code implementation process (3) model establishment

Kingbase v8r6 cluster installation and deployment case - script online one click capacity reduction
随机推荐
Little black gnawing leetcode:589. Preorder traversal of n-ary tree
-Bash: wget: command not found
Merge sort
黑色的的一站式运维管家 10条记录RO
To 3mm; Provide safe and stable product execution according to the sender IID
What is the proper resolution of the computer monitor? Introduction to the best resolution of monitors of various sizes and the selection of different wallpapers
Share a login interface template of QT implementation
How to play the Microsoft twin tool twinsonot? Introduction to twin test tool twinornot
激活函数和最常用的10个激活函数
打印1000年到2000年之间的闰年
Learn more about the new features of ES6 in grain mall of e-commerce project
[2023 core technology approval test questions in advance] ~ questions and reference answers
Export function called separately
Common cross domain problems
Nautilus 3.19.2 adds momentum to Gnome
Determined by hardware (see official 2 and
Rlib learning - [4] - algorithmconfig detailed introduction [pytoch version]
作、Ho量有关。嵌入,只有一70的该接
Engineer competency model and skill requirements
Threejs+shader drawing commonly used graphics