<cfscript>
dsService = createObject('java','coldfusion.server.ServiceFactory').getDataSourceService();
datasourceFactory = createObject("java", "coldfusion.sql.DataSourceFactory").getInstance();
extraParams = {
maxBufferSize="",
spyLogFile="",
logintimeout=0,
_logintimeout=0,
args="",
sendStringParametersAsUnicode=true,
port='',
JNDINAME=jndiName,
supportLinks=true,
pageTimeout="",
host="",
database="",
isj2ee=true,
informixServer="",
port="",
defaultusername="",
maxPooledStatements=1000,
TimeStampAsString="no",
datasource="",
defaultpassword="",
SID="",
systemDatabaseFile="",
isnewdb="",
UseTrustedConnection="false",
databaseFile="",
CONNECTIONPROPS=structNew(),
selectMethod="direct"
};
dsnMap = {
name=dsnName,
password='',
isj2ee=true,
driver='jndi',
url=jndiName,
class="",
type="jndi",
urlmap=extraParams,
timeout=javacast("float",1200),
interval=javacast("float",420),
type="J2EE",
disable=false,
disable_blob=true,
disable_clob=true,
pooling=false,
create=true,
alter=false,
select=true,
update=true,
insert=true,
delete=true,
blob_buffer=524288000,
buffer=524288000,
storedproc=true
};
datasourceFactory.setDataSource(dsnName,createObject("java", "coldfusion.sql.DataSourceDef").init(dsnMap));
</cfscript>
You might look into adding logic into your application.cfc that includes the right environment cfm for the current subdomain. In that cfm, you can set application-specific data sources to be loaded for that domain.
Of course, if you really want to stick with JNDI, and are handy with Java, you could write a wrapper JDBC driver that just proxies to a configured JNDI data source, then add your datasources as custom connections to the Lucee web admin for that site.