Revised code:
<CFOBJECT ACTION="">   TYPE="JAVA"
  CLASS="coldfusion.server.ServiceFactory"
  NAME="factory">

  <!-- new ds insert -->  
  <cfscript>
    ds = 'coldfusion.server.ServiceFactory.DataSourceService.datasources';
    // neither work;  
    // ds = '#factory#.DataSourceService.datasources';

    ds = StructNew();
    StructInsert(ds, "CLASS", "macromedia.jdbc.MacromediaDriver");
    StructInsert(ds, "DRIVER", "MSSQLServer");
    StructInsert(ds, "NAME", "#FORM.dsName#");
// StructInsert(ds, "DATABASE", "#FORM.dbName#");
// StructInsert(ds, "HOST", "#FORM.serverName#");
// from the ds dump it seems that urlmap is parallel to CLASS etc,
// hence, I changed it to the following, structure inside structure

urlPath = 'coldfusion.server.ServiceFactory.DataSourceService.datasources.urlmap.CONNECTIONPROPS';
urlPath = StructNew();
     StructInsert(urlPath, "DATABASE", "#FORM.dbName#");
     StructInsert(urlPath, "HOST", "#FORM.serverName#");
StructInsert(urlPath, "PORT", "1433");
StructInsert(urlPath, "SELECTMETHOD", "direct");
StructInsert(urlPath, "SENDSTRINGPARAMETERSASUNICODE", "false");

    StructInsert(ds, "username", "#FORM.un#");
    StructInsert(ds, "password", "coldfusion.server.ServiceFactory..DataSourceService.encryptPasword(FORM.pwd)");
    // StructInsert(ds, "password", "#CFencrypt(FORM.pwd)#");         
  </cfscript>  

<cfdump var = "#factory.DataSourceService.datasources#">
<cfoutput>
  #var#
</cfoutput>
<p>

<!--- Get datasource service --->
  <CFSET dsService=factory.getDataSourceService()>
<!--- Validate DSN --->
<CFSET result=dsService.verifyDatasource("#FORM.dsName#")>
  
<!--- If any error, return FALSE --->
<CFCATCH TYPE="any">
  <CFSET result="#cfcatch.detail#">
</CFCATCH>
</CFTRY>

<P>

<cfoutput>
result: '#result#'
</cfoutput>

Execution results:
1) cfdump displays all datasources of the CFMX installation YET the new ds is not added;
2) error code/msg/detail is EMPTY

IMHO, password encryption is critical as well.  Much appreciated.

Don

> Chunshen (Don) Li wrote:
>
> > I've realized without MM inside knowledge one can't accomplish the
> task. Have you done anything similar?
>
> I have done it without the passwords.
>
> What is the error message?
>
> Jochem
>
> --
> When you don't want to be surprised by the revolution
> organize one yourself
     
> - Loesje
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to