0

私は JavbDB を初めて使用し、次のように既存のデータベース セルに文字列を追加する必要があります。

public boolean updateChildNodes(String filePath, String parentPath)
        throws SQLException {

    // Set new parent path for all child nodes
    String sql = "UPDATE sc_compare SET parentPath = (? || parentPath)"
            + "WHERE parentPath = ?";

    try (Connection connection = this.connect();
         PreparedStatement pstmt = connection.prepareStatement(sql)) {

        // set the corresponding param
        int i = 1;
        pstmt.setString(i++, parentPath);
        pstmt.setString(i++, filePath+"%");
        // update
        pstmt.executeUpdate();
    } catch (SQLException | ClassNotFoundException e) {
        System.out.println("updateChildNodes() "+e.getMessage());
        return false;
    }

    return true;
}

呼び出しの例:

updateChildNodes("/old path/", "/new_parent");

既存のエントリ「/old_path/」については、「/new_parent/old_path/」が必要です。

準備されたプレースホルダーの代わりに、前に追加された文字列として TAG を受け取ります。

JavaDB連結で準備された文字列を使用することは可能ですか?私が間違っていることは何ですか?

4

0 に答える 0