> I just got an email from Rafael Quinones confirming that JavaCast()
> should work:
>
> <cfset DBpassword="mypassword">
> <cfscript>
> factory = CreateObject("java", "coldfusion.server.ServiceFactory");
> ds_service = factory.datasourceservice;
> dsources = ds_service.datasources;
> </cfscript>
> <cfset encryptedDBpassword = #ds_service.
> encryptPassword(JavaCast("String", "#DBpassword#"))#>
>
Thanks, Jochem. There seems a couple of possible problems:
* passed parameters for MS SQL Server (currently) are:
a) new datasource name;
b) database name;
c) server name;
d) username;
e) password
I thought they should be sufficient
* in object hierarchy.
Currently,
<CFOBJECT ACTION=""> TYPE="JAVA"
CLASS="coldfusion.server.ServiceFactory"
NAME="factory">
<cfscript>
ds_service = factory.DataSourceService;
ds = StructNew();
ds.CLASS = "macromedia.jdbc.MacromediaDriver";
ds.DRIVER = "MSSQLServer";
ds.NAME = FORM.dsName;
ds.DATABASE = FORM.dbName;
ds.HOST = FORM.serverName;
ds.username = FORM.un;
ds.password ="";
// ds.password = ds_service.encryptPasword("#FORM.pwd#");
// ds.password = ds_service.encryptPasword(javaCast("string",FORM.pwd));
ds.CONNECTIONPROPS = StructNew();
CONNECTIONPROPS.DATABASE = FORM.dbName;
CONNECTIONPROPS.HOST = FORM.serverName;
CONNECTIONPROPS.PORT = "1433";
CONNECTIONPROPS.SELECTMETHOD = "direct";
CONNECTIONPROPS.SENDSTRINGPARAMETERSASUNICODE = "false";
// You might need to fix the following line, don't know if URLMAP
// is the correct name
ds.urlmap = ds.CONNECTIONPROPS;
{ Alternatively,
urlP = StructNew();
urlLevel2 = urlP;
urlLevel2 = StructNew();
urlLevel2.CONNECTIONPROPS = StructNew();
urlLevel2.CONNECTIONPROPS.DATABASE = FORM.dbName;
urlLevel2.CONNECTIONPROPS.HOST = FORM.serverName;
urlLevel2.CONNECTIONPROPS.PORT = "1433";
urlLevel2.CONNECTIONPROPS.SELECTMETHOD = "direct";
urlLevel2.CONNECTIONPROPS.SENDSTRINGPARAMETERSASUNICODE = "false";
// You might need to fix the following line, don't know if URLMAP
// is the correct name
ds.urlmap = urlLevel2;
failed as well
end Alternatively
}
ds_service["datasources"][FORM.dsName] = ds;
</cfscript>
<cfset dspwd = "#ds_service.encryptPasword(javaCast("string",FORM.pwd))#">
LINE of ds_service["datasources"][FORM.dsName] = ds;
Complained "java.lang.IllegalArgumentException" for HOST=127.0.0.1
changed the LINE to
ds_service["datasources"]["#FORM.dsName#"] = ds
does not help.
It seems the new datasource has not been captured/recorded even if initial password was set to nothing.
There could other cause of problem, I just lost train of thought. Thanks again.
Don
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

