Reputation: 45
I have this code working for coldfusion, but when i port it to lucee it fails, i know that macromedia does not work in lucee, how can i make this a possibility in lucee and want to remove the connection string, but the result should be exactly like the how the function is returning me
// open a connection to the database
Class = createObject("java", "java.lang.Class");
Class.forName("macromedia.jdbc.sqlserver.SQLServerDriver");
manager = createObject("java", "java.sql.DriverManager");
connectionURL = "jdbc:macromedia:sqlserver://"& SESSION.USER.dbServer &":"& SESSION.USER.dbPortNumber & ";EncryptionMethod=SSL;ValidateServerCertificate=false;";
connection = manager.getConnection(connectionURL, SESSION.USER.dbUser, SESSION.USER.dbPass);
Upvotes: 0
Views: 604
Reputation: 14859
You might define this data source in the Admin instead of in the application code. One thing that screams "big red flag" in your existing code is that the database server name is defined in a cookie. Makes me wonder what other things are in cookie values that need to be refactored.
Read the documentation for defining a data source:
this.datasources["myds"] = {
class: 'org.gjt.mm.mysql.Driver'
, connectionString: 'jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8&useLegacyDatetimeCode=true'
, username: 'root'
, password: "encrypted:5120611ea34c6123fd85120a0c27ab23fd81ea34cb854"
};
The example is for MySQL, but you need to find the correct driver name for SQL Server used by Lucee. Go to the admin and create the DSN there to find the driver name.
Upvotes: 1