Java does not run prepare statements with parameter

孤人 提交于 2019-12-06 02:16:44

Do you get this error if you try binding values from the shown sql and excute it from the SQL prompt or any SQL editor? Make sure your query is not having semicolon (";") at the end of it or anywhere in the query.

try giving it this way..

String query="Select favoritefood from favoritefoods where catname = ?";
preStat = conn.preparedStatement(query);  // conn is the connection object
preStat.setString(1,"Cappuccino");
ResultSet resultSet=preStat.executeQuery();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!