Reputation: 11120
I am looking to get the DB server and database info from the Datasource name.
I have tried using <cfdbinfo>
but it doesn't seem to have any of that information
<cfdbinfo
type="dbnames"
datasource="#dsn#"
name="dbdata">
<cfoutput>
The #dsn# data source has the following databases:<br />
</cfoutput>
<cfdump var="#dbdata#">
I am looking to get the info highlighted in yellow
Upvotes: 0
Views: 635
Reputation: 20794
Here is another method my co-worker came up with several years ago.
<cfobject type="JAVA" action="Create" name="factory"
class="coldfusion.server.ServiceFactory">
<cfscript>
sqlexecutive = factory.getDataSourceService();
//get data sources
ds=sqlexecutive.getDatasources();
</cfsript>
Not sure if it's better or worse than Andrew's methods, but it's nice to have options.
Upvotes: 0
Reputation: 1069
You will need to create an object of the admin API, login and then create an object of the datasource API as follows:
<cfset admin_api = createObject('component', 'cfide.adminapi.administrator')>
<cfset admin_api.login('cf_admin_password_here')>
<cfset admin_api_dsn = createObject('component', 'cfide.adminapi.datasource')>
Then from there you can use the methods exposed by the datasource API to retrieve the information you require.
Another option would be to read in the file neo-datasource.xml
from the {cf_root}/lib/ directory
, parse that using xmlparse and then read the data from there.
Upvotes: 1