本文介绍了MySQL结果集-未为参数1指定值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我无法弄清楚该错误的含义或解决方法.我正在尝试从我的一个数据库中检索一些数据,但是继续遇到下面的错误消息.
I can't figure out what this error means or how to fix it. I'm trying to retrieve some data from one of my databases but keep running into this error message below.
preparedStatement = connect
.prepareStatement("SELECT * FROM mydatabase "
+ " WHERE TickerID=?");
resultSet = preparedStatement.executeQuery(); //where it says the error is, line 132
while(resultSet.next())
{
aIDTA = resultSet.getInt("AccountID");
nameTA = resultSet.getString("Name");
CashBalance = resultSet.getDouble("CashBalance");
TradeFeeBuy = resultSet.getDouble("TradeFeeBuy");
TradeFeeSell = resultSet.getDouble("TradeFeeSell");
AssetsBalance = resultSet.getDouble("AssetsBalance");
}
Exception in thread "main" java.sql.SQLException: No value specified for parameter 1
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:996)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:935)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:924)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:870)
at com.mysql.jdbc.PreparedStatement.checkAllParametersSet(PreparedStatement.java:2281)
at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:2261)
at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:2191)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2004)
at BuyAndSell.BuyAndSell(BuyAndSell.java:132)
at Main.main(Main.java:21)
推荐答案
您需要在PreparedStatement
preparedStatement.setLong(1, someIdentifier)
这篇关于MySQL结果集-未为参数1指定值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!