JDBC prepareStatement doesn't work

前端 未结 4 1416
北恋
北恋 2020-12-07 06:08

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 va

4条回答
  •  Happy的楠姐
    2020-12-07 06:31

    It has nothing to do with jdbc, prepared-statements or mysql.
    It's just a wrong sql statement.

    If you type:

    Select 'justanexample' from Vehicle
    

    and the table contains 4 lines, you will get 4 times

    'justanexample'
    'justanexample'
    'justanexample'
    'justanexample'
    

    as result.

    You did not specify your the table structure, but I guess the statement should somehow look like this:

    select * from Vehicle where license = ?
    

提交回复
热议问题