Setting JNDI datasources in lucee ( programmatically )

84 views
Skip to first unread message

Arthur

unread,
Jun 16, 2016, 11:37:31 AM6/16/16
to Lucee
Here is the ACF code that I am trying to convert to lucee. Does anyone know how this could be accomplished? Thanks in advance !!!


<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>



Jesse Shaffer

unread,
Jun 17, 2016, 9:02:25 AM6/17/16
to Lucee
I don't believe Lucee supports JNDI data sources at this time. Are you deploying your app as a WAR?

Arthur

unread,
Jun 17, 2016, 2:55:27 PM6/17/16
to Lucee
Yes, but the datasources are supposed to be set after the application has started based on the subdomain the user is in.

Jesse Shaffer

unread,
Jun 17, 2016, 3:28:45 PM6/17/16
to lu...@googlegroups.com

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.

Jesse Shaffer

unread,
Jun 17, 2016, 3:34:19 PM6/17/16
to lu...@googlegroups.com

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.

Arthur

unread,
Jun 17, 2016, 4:16:31 PM6/17/16
to Lucee
Quick question, even if you were to use JDBC, how would you add the datasource? The does not seem to be a method for it.

Art
Reply all
Reply to author
Forward
0 new messages