PlugIns JdbcSlim UserGuide 3HowtoConfigureTheDatabaseConnection
Instead of creating a new connection for each SQL command table a connection can also be reused.
Add the property DBConnection to your configuration and give the connection a unique name.
The connection stays now open and will be reused for all SQL statements which have the same DBConnection property.
IMPORTANT: Don't forget to close the connection at the end of your tests and remove it from the internal list of available connections.
Define a connection and assign it a name with the DBConnection key.
| Define Properties | NamedConnection |
| key | value |
| .include | TestDatabase |
| DBConnection | TestConnection |
The connection will be opened at the first usage
| SQLCommand | NamedConnection | select ID, NAME from TestData where Name ='%NAME%' |
| ID? | NAME | |
| 2 | Ben | |
| 5 | Sarah | |
This will reuse the connection. Apart from the DBConnection name no further property is required.
| Define Properties | ReuseConnection |
| key | value |
| DBConnection | TestConnection |
| CMD |
| SQLCommand | ReuseConnection | select ID, NAME from TestData where Name ='%NAME%' |
| ID? | NAME | |
| 2 | Ben | |
| 5 | Sarah | |
Close the connection and remove it from the list of available connections
| Script: SQLCommand | ReuseConnection |
| closeConnection | |
| removeConnection | TestConnection |
Another access to the connection will fail
| comment: SQLCommand | ReuseConnection | select ID, NAME from TestData where Name ='%NAME%' |
| ID? | NAME | |
| Ben | ||
| Sarah | ||