mysql问题
YouhaveanerrorinyourSQLsyntax;checkthemanualthatcorrespondstoyourMySQLserverversionfo...
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?0' at line 1
这是我写的代码,求看看是哪里的错误,万分感谢
public ResultSet getStock_ID(Stock stock) {
ResultSet ID;
Connection conn = null;
PreparedStatement ps = null;
ResultSet rs = null;
try {
conn = JdbcUtils.getConnection();
String sql = "select stock_id from gpxx where stock_name=?" + stock.getstock_id();
ps = conn.prepareStatement(sql);
//ps.setString(1, stock.getstock_name());
ID = ps.executeQuery(sql);
} catch (SQLException e) {
throw new exception(e.getMessage(), e);
} finally {
JdbcUtils.free(rs, ps, conn);
}
return ID; 展开
这是我写的代码,求看看是哪里的错误,万分感谢
public ResultSet getStock_ID(Stock stock) {
ResultSet ID;
Connection conn = null;
PreparedStatement ps = null;
ResultSet rs = null;
try {
conn = JdbcUtils.getConnection();
String sql = "select stock_id from gpxx where stock_name=?" + stock.getstock_id();
ps = conn.prepareStatement(sql);
//ps.setString(1, stock.getstock_name());
ID = ps.executeQuery(sql);
} catch (SQLException e) {
throw new exception(e.getMessage(), e);
} finally {
JdbcUtils.free(rs, ps, conn);
}
return ID; 展开
展开全部
哥们,记混了吧,,,,,String sql = "select stock_id from gpxx where stock_name= 【?】" + stock.getstock_id();,,,,,这句话貌似不能有?吧。。。。多看看prepareStatement和statement的区别。。。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询