1

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?

metamagikum
  • 1,307
  • 15
  • 19
  • 1
    What exactly is your question? Do you get an error? If yes, what is the **exact** error message? If no, then what is the problem? –  Aug 23 '16 at 11:50
  • I've added the details to the description. The prepared string occours as empty tab. – metamagikum Aug 23 '16 at 14:15

0 Answers0