不显示删除回复显示所有回复显示星级回复显示得分回复 com.microsoft.sqlserver.jdbc.SQLServerException: 索引 1
各位大侠 帮帮忙吧 实在不知哪出错了
com.microsoft.sqlserver.jdbc.SQLServerException: 索引 1 超出范围。
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.setterGetParam(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.setString(Unknown Source)
at cn.com.chengang.swt.Book$10.delt(Book.java:391)
at cn.com.chengang.swt.Book$10.widgetSelected(Book.java:372)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:90)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:928)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3348)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2968)
at cn.com.chengang.swt.Book.main(Book.java:461)
索引 1 超出范围。
我的程序:
// 加载JDBC驱动
String dbURL = "jdbc:sqlserver://localhost:1433; DatabaseName=library";
// 连接服务器和数据库library
String userName = "sa"; //默认用户名
String userPwd = "123"; //密码
Connection dbConn = null;
PreparedStatement stmt=null;
String BookNOTexts=BookNOText.getText().trim();
try {
Class.forName(driverName);
dbConn = DriverManager.getConnection(dbURL, userName, userPwd);
stmt=dbConn.prepareStatement("delete from Book where BookNO=?");
stmt.setString(1,BookNOTexts);
stmt.executeUpdate();
int res=stmt.executeUpdate();
} catch (ClassNotFoundException a) {
System.out.println(a.getMessage());
} catch (SQLException edd) {
edd.printStackTrace();
System.out.println(edd.getMessage());
} finally{
try {
stmt.close();
dbConn.close();
} catch (SQLException a) {
// e.printStackTrace();
}
}