Lucee <cfadmin> does not correctly store connectionString property when executing an "updateDatasource" operation

Description

I'm hoping someone can shed some light on this issue. I'm attempting to programmatically add datasources to the Lucee Server context (ie. not on a per-application basis, but rather datasources that are made available to all web contexts on the server). The following call to the <cfadmin> tag to create the datasource (NOTE: "updateDatasource" creates datasources if they don't already exist) or later update the same datasource results in the connectionString never being saved correctly.

<cfadmin action="updateDatasource" type="server" password="F4K31234" bundlename="org.lucee.mssql" bundleversion="8.4.1.jre8" classname="com.microsoft.sqlserver.jdbc.SQLServerDriver" dsn="my_new_datasource" name="my_new_datasource" newName="my_new_datasource" connectionString="jdbc:sqlserver://SQLSERVERNAME\MSSQLSERVER2019;DATABASENAME=my_database;sendStringParametersAsUnicode=true;SelectMethod=direct" dbusername="Temp1234" dbpassword="F4K31234" connectionLimit="100" alwaysSetTimeout="true" validate="false" allowed_select="true" allowed_insert="true" allowed_update="true" allowed_delete="true" allowed_create="true" allowed_revoke="true" allowed_alter="true" allowed_grant="true" clob="true" lineTimeout="60">

Every time this operation is attempted, the Connection String is stored as "my_database". In other words, it appears to ignore the string provided in the connectionString attribute and instead stores the database name or one of the values from the "dsn", "name", or "newName" attributes for the datasource connection string.

This invalid value is proven by editing the datasource within the Lucee Server administrative area or by running another call to <cfadmin> "getDatasource".

Environment

Host: Windows Server 2019 running x64 Tomcat and Lucee 5.3.8.206 and OpenJDK17.
Database server: Windows Server 2019 running SQL Server 2019

Activity

Show:

Ryan Covert 10 November 2021 at 14:28

Thank you for the response! I’ll investigate the use of the code you have outlined here. Much appreciated!

Alternatively, I have also since found that cfconfig via CommandBox is a viable solution as well. It obviously requires the use of an external process, but I am not against that practice for the application in question.

Either way, I’m impressed with the Lucee development team’s attention to detail and the care they put into helping out the community. You’re a great bunch. slightly smiling face

Pothys - MitrahSoft 10 November 2021 at 08:56
Edited

, As per comments in the linked tickets, the cfadmin tag is not an official tag to use outside of lucee admin. So please use Administrator.cfc instead of cfadmin tag.

For update or create datasource outside of admin use updateDatasource method in Administrator.cfc. If you face any issues in using Administrator.cfc means please feel free to add a comment here.

<cfscript> adm = new Administrator("server", "server_admin_password"); adm.updateDatasource( type: "MSSQL", name:"my_new_datasource", newName: "my_new_datasource", host: host, port: port, database: "database_name", username: username, password: password, allowedSelect=true, allowedInsert=true, allowedUpdate=true, allowedDelete=true, allowedAlter=true, allowedDrop=true, allowedRevoke=true, allowedCreate=true, allowedGrant=true, connectionLimit: 100, storage: false, blob: true, clob: true ); </cfscript>
Fixed

Details

Assignee

Reporter

Priority

Labels

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Affects versions

Created 9 November 2021 at 15:48
Updated 6 January 2022 at 06:07
Resolved 17 November 2021 at 12:27

Flag notifications