Apache Derby (JavaDB) concatenation regarding SQL92T (Prepend String to existing dataset)

74 Views Asked by At

I am new with JavbDB and need to simply append a string to a existing database cell like this:

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;
}

Example call:

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

For the existing entry "/old_path/" i expect "/new_parent/old_path/".

I receive a TAG instead of the prepared placeholder as prepended string.

Is this possible to use prepared strings with JavaDB concatenation and what i am doing wrong?

0

There are 0 best solutions below