I'm needing to connect to a database manually (not using cfquery). However I'm
not wanting to hardcode the password into the file. I have a datasource defined
already that I can read using
coldfusion.server.ServiceFactory.getDataSourceServ ice(). This allows me to find
out the password for the database which is encrypted (hashed I believe). Does
anyone know of a way to connect to the database using the encrypted password?


Example of code that I'm wanting to work (problem is txtPassword is encrypted)
(assume application.dsn is already defined)

factory = createObject("java", "coldfusion.server.ServiceFactory");
dsService = factory.getDataSourceService();
strDataSources = dsService.getDataSources();
txtUserID = strDataSources[application.dsn].username;
txtPassword = strDataSources[application.dsn].password;
txtServer = strDataSources[application.dsn].urlmap.host;
txtPort = strDataSources[application.dsn].urlmap.port;
conn_url =
"jdbc:macromedia:sqlserver://#txtServer#:#txtPort#;databaseName=MyDB;SelectMeth o
d=direct;sendStringParametersAsUnicode=false";

class = createObject("java", "java.lang.Class");
class.forName("macromedia.jdbc.MacromediaDriver");
dm = createObject("java", "java.sql.DriverManager");
con = dm.getConnection(conn_url, txtUserID, txtPassword);