Connection String - Application Name

How do I pass a CF2021 application name to the database in connection string? I tried cfconfig.json, but it does not work. I tried setting clientApplicationName, clientApplicationNamePrefix, custom, connectionString and dsn.

If I set it in data & services > data source > show advanced settings > Connection String

ApplicationName=Something Something Darkside

Then, running this query will correctly show the name set above. SELECT distinct program_name
FROM master…sysprocesses
WHERE program_name <> ‘’

relevant part from cfconfig.json, also I was trying to see if anyone of them will show up:

“MyDatabase”: {

“class”: “macromedia.jdbc.MacromediaDriver”,
“clientApplicationName”: true,
“clientApplicationNamePrefix”: “MyCFApp”,
“clientHostname”: true,
“clientUsername”: true,
“custom”: “”,
“database”: “MyDatabase”,
“dbdriver”: “MSSQL”,
“description”: “”,
“dsn”: “jdbc:macromedia:;MaxPooledStatements=49;ApplicationName=SomethingSomethingDarkside”,
“connectionString”: “ApplicationName=MyCFAppLocal”,
“host”: “sql”,

“validationQuery”: “”
},

Is this a commandbox bug? By the way, if I restart my server that connection string above is lost.

I’m not sure where you got the connectionString key from, but there no such setting name for a datasource in CFConfig! I believe what you’re looking for is custom, which is (Extra JDBC URL query string without leading &).

The JDBC URL is only used if the DB type is “Other”. This is to prevent invalid URLs from getting imported if a user is transferring Lucee config to Adobe, etc. So long as you put your custom bits in the custom field, then they should get appended to the JDBC URL. You can confirm in the neo-datasources.xml file.

I made up the connectionString, since I was desperately trying to get the Application Name sent over. I looked at other cfconfig.json params, where datasource settings are camel cased with no space. Max Pooled Statements becomes maxPooledStatements, Maintain Connections becomes maintainConnections and so on.

Adding the following,“custom”: “ApplicationName=DoesThisWork”, actually does not work. This query or sp_who2 will not show “DoesThisWork”

SELECT distinct program_name
FROM master…sysprocesses
WHERE program_name <> ‘’

Where is your neo-datasource.xml on commandbox with docker? I cannot find it.

If you look at the help on the

cfconfig datasource save ?

command you can see what the options are. Also, setting up the datasource the way you want it in the web admin and then simply exporting those settings to JSON is the easiest way to get the correct JSON.

In the server home with the rest of the XML files. I have no idea how you’ve set up your docker image, but if you SSH into your docker image and run

box server info property=serverHomeDirectory

in the web root of the server, it should take you to where the CF engine lives. Or, just experiment on a local server outside of Docker where it’s 100 times easier to debug this sort of stuff.

Ok, I just tried this locally real quick and it 100% worked. I spun up a CF 2021 server and added the following to the web admin in the advanced datasource settings:

I then exported that config to a JSON file

cfconfig export .cfconfig.json

which included this bit inside the datasource object:

"custom":"ApplicationName=DoesThisWork",

I then restarted the server so it would load in the .cfconfig.json file fresh and I ran your sysProcesses query and DoesThisWork shows up in the list of application names.

The setting looks like this inside the neo-datasources.xml file:

image

When I restart the docker container from Docker Desktop, the connection string in CF Admin is gone.

I don’t know if you’re expecting anyone here to somehow read your mind (or the contents of your hard drive), but there’s no telling why :slight_smile: I would start by making sure haven’t removed it from your .cfconfig.json file that gets imported when the server starts. I’d also confirm what json files CFConfig is loading to ensure you’re editing the right one.