I have some data in a old MSSQL 2000 db. I am trying to move a couple tables from it to a mySQL (V 5.025) db. In the past I created a flat csv files from the MSSQL db and imported into an empty desination table in the mySQL db using this code snippet:
LOAD DATA INFILE '/moodle/sourcefile.csv' INTO TABLE tablename
FIELDS TERMINATED BY ','
I would like to do a direct, programmatic selection from source, insert into destination process. I am using Coldfusion (MX) to read from the MSSQL table, which is getting the data from the source db fine.
I have created a connection object using this code:
classLoader = createObject("java", "java.lang.Class");
classLoader.forName("sun.jdbc.odbc.JdbcOdbcDriver");
dm = createObject("java","java.sql.DriverManager");
I can dump the dm object and its fine, ready to be used.
I am attempting to create an odbc connection to the mySQL table like this: This is the code that is failing.
con = dm.getConnection("jdbc:odbc:DRIVER={MySQL ODBC 3.51 Driver}; SERVER=ipaddress; PORT=3306; DATABASE='dbname'; USER='username'; PASSWORD='password'; OPTION=3;");
The error it is generating is
“[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified”
Any ideas on how to correct this error (make connection work) OR a different perspective on how to move this data is appreciated.
You have to have the bridge connector installed to do this. On windows it’s 2 separate services titled ColdFusion ODBC Server and ColdFusion ODBC Agent.
In addition you might run into issues with 64bit vs. 32bit. You may need to install your sys dsn using a different odbc server commandlet (check the WOW64 folder). check out this post for some work arounds related to Access (which also bridges through ODBC).
http://www.coldfusionmuse.com/index.cfm/2010/12/31/Access.on.64bit.ColdFusion
Also – you should know that you CAN set this up with the latest driver even on an older CF version. You have to get the driver file into the class path and then use the “other” JDBC type. It requires creating a JDBC connection string etc. – but probably as easy or easier than trying to jury rig the ODBC subsystem. Good luck 🙂