当前位置:网站首页>JDBC使用预编译执行DQL语句输出都是占位符内容,这是为什么呢?
JDBC使用预编译执行DQL语句输出都是占位符内容,这是为什么呢?
2022-04-22 03:28:00 【CSDN问答】
public class JDBCtest02 {
public static void main(String[] args) {
Connection conn=null;
PreparedStatement ps=null;
ResultSet rs=null;
try { Class.forName("com.mysql.cj.jdbc.Driver"); conn= DriverManager.getConnection("jdbc:mysql://localhost:3306/class","root","123456");//这是一个工具方法 String sql="select ? from class"; //DQL语句 ps=conn.prepareStatement(sql); //编译 ps.setString(1,"name"); //输入占位符 rs=ps.executeQuery(); //执行 while (rs.next()){ //遍历 String aname=rs.getString(1); System.out.println(aname); } } catch (Exception e) { e.printStackTrace(); }finally { JDBCUtil.close(conn,ps,rs);//释放方法 }}
}
采纳答案:
占位预编译成字符串了
同等 select 'name'
版权声明
本文为[CSDN问答]所创,转载请带上原文链接,感谢
https://ask.csdn.net/questions/7691935
边栏推荐
- Web automation master card in file upload and pop-up processing?
- moudle中的activity跳转到主项目的activity
- Summarize the differences between queue: work and queue: listen
- docker启动redis官方镜像的三个警告的通用解决办法
- [leetcode daily question] 824 Goat Latin
- Full summary of 18 tax categories of tax law with memory tips
- Laravel 超好用代码提示工具 Laravel IDE Helper
- L'utilisation de la file d'attente résume les différences entre la file d'attente: travail et la file d'attente: Listen
- Recruitment - long term effectiveness
- Ros2 learning notes (V) -- Summary of common instructions for ros2 command line operation (I)
猜你喜欢

An article gives you a preliminary understanding of the basic knowledge of C language operators

吉他樂理整理

Comparison based on numerical differentiation and error back propagation

Technology sharing | selenium ide use case recording

Zabbix5 series - monitor Huawei and H3C switches (snmpv2c / SNMPv3 / snmptrap) (II)

Installing MySQL on Linux
![C language daily question -- [noip2008] ISBN number (question 76 of niuke.com)](/img/a5/d6869747e2a61d076b4763021be123.png)
C language daily question -- [noip2008] ISBN number (question 76 of niuke.com)

Memory distribution of stm32

Realization of Yang Hui triangle in C language

Finition musicale de guitare
随机推荐
Ink back words -- extract all its offline words through the installation package
Bad config encountered during initialization:/ No such notebook dir:
Polyfill是什么?
ForkJoin
Allegro gerber文件路径设定
2021-10-21 software testing theory
吉他樂理整理
队列使用问题总结 queue:work和queue:listen的区别
Saas. Extended field custom field
Use of uiautomator2 automated test tool
Computer wechat built-in browser turns on debugging mode
wangEditor富文本编辑器使用、编辑器内容转json格式
php. Ini configuration
Third season recruitment of cognitive computing neuroscience online reading club
Database Basics
The wangeditor rich text editor uses and converts the content of the editor to JSON format
C language constant, string, escape character, initial level of annotation
Allegro Gerber file path setting
Recruitment - long term effectiveness
2021-10-19 performance test