JDBC prepareStatement不起作用 [英] JDBC prepareStatement doesn't work
本文介绍了JDBC prepareStatement不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用prepareStatement
函数.代码如下.执行后,它返回给我一堆vlicense
字符串,而不是值.
I'm trying to use the prepareStatement
function. The code is below. After it executes, it returns me a bunch of vlicense
strings instead of the values.
当代码完成statement.setString()
时,该语句变为:
When the code finishing the statement.setString()
, the statement becomes:
select 'vlicense' from Vehicle
但是,它必须是:
select vlicense from Vehicle
,不带引号.谁能告诉我这是什么问题?
without the quotation marks. Can anyone tell me what's the problem?
statement = oConnection.prepareStatement("select ? from Vehicle");
String tempString = "vlicense";
statement.setString(1, tempString);
resultSet = statement.executeQuery();
推荐答案
您不能将参数标记用于列名,表名,数据类型名或基本上不是数据的任何内容.
You can't use parameter markers for column names, table names, data type names, or basically anything that isn't data.
这篇关于JDBC prepareStatement不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文