Get SRConnection for Project's Default Database

How can I go about getting an SRConnection object for the project’s default database? We’ve got a Gateway module and we’re able to get them through GatewayContext.getDatasourceManager().getConnection(); however, ClientContext doesn’t have a getDatasourceManager() method, just getDefaultDatasourceName(). I’ve been cruising through the API javadocs but can’t seem to find what I’m looking for.


You don’t get an SRConnection from the client.

All database stuff goes through the GatewayInterface if you’re in the client/designer. You get the GatewayInterface from GatewayConnectionManager.getInstance().getGatewayInterface()

From here you can run queries. If you leave the database connection name blank, it run’s against the project’s default.

We’re using a third-party library for database interactions, thinking about moving towards a full-blown ORM in the future. When querying, we’ve got to provide our Factory object a java.sql.Connection …

SRConnection conn = getConnection(); // Uses GatewayContext.getDatasourceManager().getConnection() DataFactory db = new DataFactory(conn); Result<VegetableRecord> results = db.selectFrom(Tables.VEGETABLE).where(Tables.VEGETABLE.COLOR.equal("Red")).fetch(); So, that’s the reasoning behind my request for an SRConnection object. We’ve got all the querying logic encapsulated in repositories; however, without a Connection object, we can’t make use of these repositories at the Client/Designer level.