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


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

标签: derby concat javadb ansi-sql-92
© 2014 TuiCode, Inc.