服务器:Null java.sql.SQLException参数索引超出范围(1>;参数数,即0)

服务器:Null java.sql.SQLException参数索引超出范围(1>;参数数,即0),java,mysql,sql,sql-server,netbeans,Java,Mysql,Sql,Sql Server,Netbeans,错误如下: Error - This signifies the try catch statement with sql Oct 29, 2017 5:19:43 PM tenantcheck.Check jButton1MouseClicked SEVERE: null java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0). 代码 p

错误如下:

Error - This signifies the try catch statement with sql  
Oct 29, 2017 5:19:43 PM tenantcheck.Check jButton1MouseClicked   
SEVERE: null     
java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0). 
代码

private void jButton1MouseClicked(java.awt.event.MouseEvent evt){
连接con=null;
Statement=null;
试一试{
con=DriverManager.getConnection(CONN_字符串、用户名、密码);
如果(con==null){
System.out.println(“连接到数据库”);
}
弦乐;
试一试{
statement=con.createStatement();
}catch(SQLException-ex){
Logger.getLogger(Check.class.getName()).log(Level.SEVERE,null,ex);
System.out.println(“Didnt-Werk”);
}
String name=JOptionPane.showInputDialog(“请输入租户名称”);
int dialogButton=JOptionPane.YES\u NO\u选项;
int dialogResult=JOptionPane.showConfirmDialog(null,“信用检查机构是否已批准?”,“重要”,dialogButton);
if(dialogResult==JOptionPane.YES\u选项){
Cred=“是”;
//在这里保存代码
}
否则{
Cred=“否”;
}   
double income=double.parseDouble(JOptionPane.showInputDialog(“请输入租户收入”);
double BalSet=double.parseDouble(JOptionPane.showInputDialog(“请输入租户”);
双倍货币租金=0.7*收入;
如果(Cred==“否”| | BalSet<0 | |收入<5000){
showMessageDialog(null,“用户不符合任何属性的条件”);
}
否则{
试一试{
String insertQuery=“从单位中选择*,其中“+moneyrent+”=>成本和占用=1;”;
PreparedStatement pstmt=con.prepareStatement(插入查询);
pstmt.setDouble(1,货币租金);
语句.execute(insertQuery);
setText(insertQuery);
//语句.execute(insertQuery);
}catch(SQLException-ex){
Logger.getLogger(Check.class.getName()).log(Level.SEVERE,null,ex);
System.out.println(“错误”);
}
}    
}捕获(例外e){
系统输出打印项次(“未连接”);
}

}
您的preparedStatement中没有任何参数,但您尝试填写一个参数:

pstmt.setDouble(1,moneyrent);
您的准备声明应为:

SELECT * FROM unit WHERE Cost >= ? And Occupied = 1
这是有效的:),但是我如何显示准备好的语句@AlexmtXtnit.setText(insertQuery.replace(“?”,moneyrent))@ReubenSousa