The question you mentioned (Is every number in the code considered a “magic number”?) is arguably a duplicate of this one, but maybe we can add some more info here.
The first major problem with
connection.setLoginTimeout(30);
Is that you're assuming the junior developer you just hired who's looking at this 6 months from now will know that "30" is seconds & not milliseconds.
The second major problem (as @KilianFoth pointed out in a comment) is that again, 6 months from now, that junior developer might not be able to find this parameter very easily if at all.
An important point not brought up in your examples or the examples in the other question is that there is absolutely no reason to declare the constant right next to where it's used.
Instead, stick all of those "tuning parameters" in a common well documented place - perhaps a Constants.h file or equivalent.