private void toggleSelectedJDBCDataSourceConnection() {

		BSimServerInfo serverInfo = serverTable.getSelectedRowObject();
		if (serverInfo == null || serverInfo.getDBType() == DBType.elastic) {
			return;
		}

		BSimJDBCDataSource dataSource = BSimServerManager.getDataSourceIfExists(serverInfo);
		if (dataSource == null) {
			// connect
			dataSource = BSimServerManager.getDataSource(serverInfo);
			try (Connection connection = dataSource.getConnection()) {
				// do nothing
			}
			catch (SQLException e) {
				Msg.showError(this, rootPanel, "BSim Connection Failure", e.getMessage());
			}
		}
		else {
			dataSource.dispose();
		}
		serverTableModel.fireTableDataChanged();
		notifyContextChanged();
	}
Dialog for managing BSim database server definitions
Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/gui/search/dialog/BSimServerDialog.java