public ResultSet query(String sql,String[] para)
{
try {
ps=ct.prepareStatement(sql);
//对sql的参数赋值
for(int i=0;i<para.length;i++)
{
ps.setString(i+1, para[i]);
}
//执行查询
rs=ps.executeQuery();
} catch (Exception e) {
e.printStackTrace();
// TODO: handle exception
}
//返回结果集
return rs;
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Invalid parameter binding(s).
at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.microsoft.jdbc.base.BasePreparedStatement.validateParameterIndex(Unknown Source)
at com.microsoft.jdbc.base.BasePreparedStatement.setObjectInternal(Unknown Source)
at com.microsoft.jdbc.base.BasePreparedStatement.setString(Unknown Source)
java.lang.NullPointerException
at com.mhl.model.usermodel.checkuser(usermodel.java:30)
at com.mhl.view.userlogin.actionPerformed(userlogin.java:128)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
上边的代码用debug一步步走 跳出for循环后就直接出现错误了