Progress Programmer Progress Programmer - 1 year ago 94
MySQL Question

JDBC prepareStatement doesn't work

I'm trying to use the

function. The code is below. After it executes, it returns me a bunch of
strings instead of the values.

When the code finishing the
, the statement becomes:

select 'vlicense' from Vehicle

However, it needs to be:

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();

Answer Source

You can't use parameter markers for column names, table names, data type names, or basically anything that isn't data.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download