Using Multiple Connections in an IJ test script

Sometimes when you are writing a test, it is useful to work with multiple connections inside your IJ test script.

IJ supports multi-connection scripts elegantly, using the "show connections" and "set connection" commands. There is also the ability to name a connection, so you don't have to refer to them as Connection 1, Connection 2, etc.

When you are writing an IJ script for a regression test, this feature is somewhat more subtle, because generally the connection has already been established by the test harness. You don't want to open a connection to a hard-coded URL inside the script, because that would not work with different frameworks (DerbyNet versus embedded, for example).

The solution is that you can use abbreviated connection urls in IJ, omitting the scheme and framework information from the beginning of the URL, and IJ will then use whatever framework it is currently running under.

See jdbcapi/users.sql for an example:

  • connect 'wombat;shutdown=true;user=francois;password=paceesalute';
  • connect 'myDB;create=true;user=dan;password=MakeItFaster';

Thanks to Knut Anders for this observation.

  • No labels