Get Name Of Physical DB Through Datasource?

Hey Guys,

I know that I can get the database VENDOR using

databaseManager.getDatabaseProductName(theConn)

Is there a way to get the physical database NAME (or JDBC URL is fine) from a connection name?

I’m trying to branch code based on whether the named connection is pointed to a specific database name.

Thanks!

Bob

Hi Bob,

the Usermanager plugin has the ability to read any property from the servoy.properties file.
Since this is the place where the connection information is stored, I think you should be able to retrieve it.

OK Marc - thanks.

I was hoping I didn’t have to use a plugin… but if I need to, I will.

I really appreciate your quick response! :D

Bob

Hi Bob

You could always just query it and grab a dataset with getDatasetbyquery using the desired connection.

Sql server

select DB_NAME();

MySql

SELECT DATABASE();

Postgres

SELECT current_database();
	var sql = "select DB_NAME();"
	var server = databaseManager.getDataSourceServerName(foundset.getDataSource())
	var ds = databaseManager.getDataSetByQuery(server,sql,null,1)
	application.output(ds.getValue(1,1))

That’s brilliant! Thank you very much!