Tuesday, December 1, 2026

.::: Lucee – Externalize Database Datasource Configuration from Application.cfc :::.

 

continue from https://teguhth.blogspot.com/2026/11/trouble-shoot-last-packet-successfully.html

1. Struktur direktori

ls -l /opt/lucee/tomcat/webapps/ROOT/

2. Buat config/datasources.cfm
mkdir -p /opt/lucee/tomcat/webapps/ROOT/config

[root@teguhth-lucee ROOT]# cat /opt/lucee/tomcat/webapps/ROOT/config/dbteguhth.cfm
<cfscript>

// Database teguhth
this.datasources["dbteguhth"] = {
    class: "com.mysql.cj.jdbc.Driver",
    bundleName: "com.mysql.cj",
    bundleVersion: "9.1.0",
    connectionString: "jdbc:mysql://10.10.10.60:13306/teguhth?SelectMethod=directAccess&useProcedureBodies=true&allowMultiQueries=true&useSendStringParametersAsUnicode=false&useUnicode=false&callMultiQueries=true&autoReconnect=true&tcpKeepAlive=true&alwaysResetConnections=true&socketTimeout=0&connectTimeout=30000",
    username: "admin",
    password: "encrypted:881e9bf1f53a430cbcd41a24e749e0bfd8ab7c37508d57bf",
    blob: false,
    clob: false,
    connectionLimit: 100,
    connectionTimeout: 10,
    liveTimeout: 15,
    validate: true
};

</cfscript>
[root@teguhth-lucee ROOT]#

 
3. if using other datasource dbsecretdb

[root@teguhth-lucee ROOT]# cat /opt/lucee/tomcat/webapps/ROOT/config/dbsecretdb.cfm

<cfscript>

// Database secretdb
this.datasources["dbsecretdb"] = {
    class: "com.mysql.cj.jdbc.Driver",
    bundleName: "com.mysql.cj",
    bundleVersion: "9.1.0",
    connectionString: "jdbc:mysql://10.10.10.60:13306/secretdb?SelectMethod=directAccess&useProcedureBodies=true&allowMultiQueries=true&useSendStringParametersAsUnicode=false&useUnicode=false&callMultiQueries=true&autoReconnect=true&tcpKeepAlive=true&alwaysResetConnections=true&socketTimeout=0&connectTimeout=30000",
    username: "admin",
    password: "encrypted:881e9bf1f53a430cbcd41a24e749e0bfd8ab7c37508d57bf",
    blob: false,
    clob: false,
    connectionLimit: 100,
    connectionTimeout: 10,
    liveTimeout: 15,
    validate: true
};

</cfscript>
[root@teguhth-lucee ROOT]#

 
4. Ubah Application.cfc

[root@teguhth-lucee ROOT]# pwd
/opt/lucee/tomcat/webapps/ROOT
[root@teguhth-lucee ROOT]#
[root@teguhth-lucee ROOT]# cat Application.cfc
component {

        this.Name = "Lucee";
    // Load database configuration
    include "config/dbteguhth.cfm";
    include "config/dbsecretdb.cfm";

}
[root@teguhth-lucee ROOT]#

 


5. sample access 

http://10.10.10.60:8888/sleep_timer_mysql.cfm

 


No comments:

Post a Comment

Popular Posts