java jdbc DELETE 准备好的语句将不起作用

java ojdbc DELETE PreparedStatement won't work

我正在构建一个 java 程序,该程序基本上使用 ojdbc6 驱动程序管理 oracle xe 11.2g 数据库。 我成功地编写了搜索和插入行的方法,但是使用 delete 语句的方法根本没有任何作用。

private void eliminaDipartimento()
{
    try {
        PreparedStatement myStm =database.getConnessione().prepareStatement("DELETE FROM Dipartimento WHERE Cod_DIP=? ");
        myStm.setString(1, textField_6.getText());
        myStm.executeUpdate();
    } catch (SQLException e) {new ErrorDialog("Impossibile cancellare il dato");}
}

database.getconnessione() 通过 oracle 数据源获取连接,而 ErrorDialog 基本上只是一个显示错误的对话框。 非常感谢。

试试这个:

PreparedStatement myStm =database.getConnessione().prepareStatement("DELETE FROM Dipartimento WHERE Cod_DIP=cast(? as char(5))");