1

以下のコードで「パラメータ インデックスが範囲外 (1>パラメータ数、0)」と表示されるのはなぜですか?

private void btnDeleteActionPerformed(java.awt.event.ActionEvent evt) {                                          
   String tabId = lblTableId.getText().trim();
   try { 
        DBConnection db = new DBConnection();
        Connection con = db.getConnectionMyWareHouse(Main.dwh.lblSessionWarehouse.getText());
        String query1 = "Select DWTableId,DWTableName from datawarehousetable where DWTableId=? and DWTableName=? ";
        System.out.println("OG Query ---->"+query1);
        PreparedStatement ps1 = con.prepareStatement(query1);
        ps1.setString(1, tabId);
        ResultSet rs1 = ps1.executeQuery();
        String strTN = "";
        if(rs1.next())
        {
            strTN = rs1.getString("DWTableName");
        }

        String query2 = "Delete from datawarehousetable where DWTableId= ?";
        System.out.println("OG Query ---->"+query2);
        PreparedStatement ps2 = con.prepareStatement(query2);
        ps2.setString(1, tabId);
        int rs2 = ps2.executeUpdate();

        String query3 = "Drop table " + strTN;
        System.out.println("OG Query ---->"+query3);
        PreparedStatement ps3 = con.prepareStatement(query3);
        ps3.setString(1, tabId);
        int rs3 = ps3.executeUpdate();

        JOptionPane.showMessageDialog(null, "Table deleted successfully.", "Successful", JOptionPane.INFORMATION_MESSAGE);
        con.close();
    }
    catch(Exception e) {
        e.printStackTrace();
        JOptionPane.showMessageDialog(null, "Error : " + e.getMessage(),"Error", JOptionPane.ERROR_MESSAGE);
    }    
}                                         
4

0 に答える 0