【发布时间】:2016-09-24 19:55:38
【问题描述】:
当我执行程序时,它显示错误:No value specified for parameter 1
此语句出现错误:'rowSet.execute();'
public static void main(String[] args) throws SQLException {
// Create a RowSet Instance
RowSet rowSet = new com.sun.rowset.JdbcRowSetImpl();
// Establish the Databse Connection
rowSet.setUrl("jdbc:mysql://localhost:3306/jmysql?autoReconnect=false&useSSL=false");
rowSet.setUsername("root");
rowSet.setPassword("root!@#$Mysql2016");
rowSet.setCommand("SELECT userpassword FROM user WHERE userid = ? "
+ " AND userName = ? ");
//Execute the Sql Command
rowSet.execute();
rowSet.setInt("userid", 415);
rowSet.setString("UserName", "anjeetSharma415@gmail.com");
// Display the UserPassword
System.out.print("Password : " + rowSet.getString(3));
// Close the Connetion
rowSet.close();
}
线程“main”java.sql.SQLException 中的异常:未指定值 对于参数 1 在 com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1074) 在 com.mysql.jdbc.SQLError.createSQLException(SQLError.java:988) 在 com.mysql.jdbc.SQLError.createSQLException(SQLError.java:974) 在 com.mysql.jdbc.SQLError.createSQLException(SQLError.java:919) 在 com.mysql.jdbc.PreparedStatement.checkAllParametersSet(PreparedStatement.java:2611) 在 com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:2586) 在 com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:2510) 在 com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2259) 在 com.sun.rowset.JdbcRowSetImpl.execute(JdbcRowSetImpl.java:567) 在 com.advjdbc.database.chapter.RowSetPerParepedStatement.main(RowSetPerParepedStatement.java:30)
【问题讨论】: