Is it possible to have a list of the active database servers used by this instance of the Servoy Application Server? I have to know at start of application ( in the method onSolutionOpen) which are the connections active.
Thanks a lot!
Stefania
Stefania,
have a look at databaseManager.getServerNames()
Rob
But this method returns only the server name used in the my solution! I have to have a list of the active database servers
I need that same thing. We used to be able to use plugins.maintenance.getServerNames but a few versions back that stopped working in the solution and can only be used onBeforeImport. We have a work around that we use in MS SQL but it would be much nicer to have the old functionality back that the getServerNames plugin gave us.
Why should you want to know the database server names that you don’t use in your application ?
A bit like an episode of Monty Python, a lot of names you can encounter…
Regards,
lwjwillemsen:
Why should you want to know the database server names that you don’t use in your application ?A bit like an episode of Monty Python, a lot of names you can encounter…
Regards,
Without going to deep into our data model, the short answer is that we have a different database for each of our clients. I am working on an admin tool that we can use to track logs, users, etc. In that tool I need to be able to choose an orgs DB so that the resulting solution code can perform any specified tasks on that database alone and not on one of the other organizations databases. The databases are named the same as our clients internal org name so it also helps in filtering based of of that name.
With that said, the work around I mentioned uses a SQL query as such:
var _sqlGetDBs = "SELECT * FROM sys.databases db WHERE db.state = 0 and [name] like 'XYZ%' ORDER BY [name]";
var _jsDBs = databaseManager.getDataSetByQuery('anyValidDatabaseName',_sqlGetDBs,[],200);
All of our DB’s start with ‘XYZ’ for instance so this limits the resulting data from that call to just the DB’s I’m interested in. Not sure if this type of thing will work with anything but MS SQL but worth a shot as a work around if anyone else needs to do that same type of thing.
Like I said though, the maintenance plugin did this for us previously, but sadly not now.
The UserManager plugin has the ‘getDbConnectionInfos’ function in the server object with which you achieve this.
Done this before:
var _jsServer = plugins.UserManager.Server();
var _nCount = _jsServer.getDbConnectionInfos().length;
var _aDatabase = new Array();
var _sDbName;
for (var i = 0; i < _nCount; i++) {
if(_jsServer.getSettingsProperty('server.' + i + '.enabled') == 'true') {
_sDbName = _jsServer.getSettingsProperty('server.' + i + '.serverName');
_aDatabase.push(_sDbName);
}
}
For the people not having the UserManager plugin installed yet:
Yes, I know it’s ‘another plugin’ added to your solution, but with this plugin I’ve achieved so much I couldn’t do in another way that this has become part of my basic set of plugins.
+1
Still missing a feature, where we can create new a DB Connection on the fly, without restarting Servoy!
I haven’t really seen evidence that Servoy considers votes on a ticket when prioritizing features but have you voted for this feature in JIRA? It’s SVY-3792.