oracle-samples/oracle-db-examples

ConnectionHelper Settings Ignored if a Connection with that Name Exists

slarti-b opened this issue · 2 comments

I am trying to use the Connection Helper plugin to script opening a connection over a secure tunnel. I have the plugin installed and configured to allow transient connections but not to persist them.

The problem is, if a connection exists (even an old (closed), transient one) then it tries to open that, without updating it's settings (specifically the port).

E.g.

  1. Open a connection via Connection Helper using -Foo=me@localhost:12345/foo. It creates a transient connection and connects successfully.
  2. Then close that connection but do not close SQL Developer
  3. Create a new connection using -Foo=you@localhost:9999/foo
  4. Actual: It opens the connection "Foo" - but the user is still me and the port is still 12345
    Expected: It either opens the connection "Foo" with user you and port 9999 - or at the very least shows an error if it can't

My use case is that I am writing a script to automate opening a connection over a secure tunnel to our server farm. The script creates a tunnel to the specified server and then opens SQL Developer. I am using a random local port for the tunnel, to avoid having to maintain a mapping of port->server

I would expect that for a closed (disconnected) transient connection it should just over-write the values in SQL Developer with those from the connection helper. I can see that if it was still connected, that's different (I would expect an error in that case) and that a permanent connection would also be different (maybe also an error - or at least a question).

If I close SQL Developer it works, as the transient connections are deleted. Manually deleing the connection before reconnecting also works, but it's far from ideal.

Would adding a 'delete transient connections on close' preference and flat out failing if the name already exists work for you?

That would be cheapest / easiest as I know what to do without research but I'll look in to what implementing your more fancy functionality would take.

Honestly, I thought the definition of a "transient" connection was that it did that anyway! I'm slightly confused as to what the "transient" means otherwise.

In principle, I think that if I specify details like port, they should be used. To specify "open a connection with these details" and then just ignore some of them feels wrong - either over-write or show an error.

For my specific case, i have largely worked-around this issue by caching the local port used for the tunnel per server, so I re-use the same port and next time for the same server and if the connection exists, it has the right port.