Skip to main content

Posts

Showing posts from February, 2014

A JDBC Application to Copy Data Across Databases

Requirement It is required to copy data stored in one data source to another data source having the schema structure using JDBC. Whatever data is present in selected tables of origin data source should be copied to destination data source. Challenges Different JDBC drivers require somewhat different URLs and drivers. Even though Java.sql.DriverManager simplifies need to specify correct JDBC driver by looking at the URL, it is still necessary to make sure required driver is in classpath. Furthermore Driver Manager will not be able to load sun’s JdbcOdbcDriver when it is required to access Odbc Data Sources like MS Access DB files, thus it should explicitly be loaded at application startup.  Also there might be situations as it is in MS Access, which requires matching DSN configuration, additional configurations might be necessary.  As to JDBC URLs, since they are not completely standard among different drivers, user needs to know correct construction of required JDB

Accessing MS Access using JDBC

Since Microsoft does not provide 64 bit drivers for Access; it becomes a nuisance to access MS Access under 64 bit platforms.   For a successfull connection to  MS Access DB File (*.mdb)  with  JDBC  under 64 bit platforms, follow following steps: 1-        Make sure Access drivers are installed. If access is installed it is already there, else download from  this  link and install. 2-        Configure  Data Source Name  using 32 bit  ODBC Data Source Administrator . Use the executable at c:\windows\sysWOW64\odbcad32.exe. 3-        System DSN->Add->Microsoft Access Driver (*.mdb) -            Specify a Data Source Name -            Specify a description -            Locate mdb file. -            Click OK. Picture  1  DSN Setup for MS Access Picture  2  New DSN 4-        Use code fragment below to obtain connection. private   static  Connection getConnection ()   throws  SQLException ,  ClassNotFoundException  {     Clas

Exporting MS Access to MySQL

To export an access database ( mda  file) to  MySQL  database is quiet easy. All needed is to download 32 bit  MySQL Connector/ODBC  driver  from  http://dev.mysql.com/downloads/connector/odbc/  and follow steps below. 1-      Select the table to export. 2-      From  External Data  tab select  ODBC Database . See picture below. Picture  1  ODBC Database Export 3-        Specify table name to export onto. Typically the same name as the access table name. 4-         From  Select Data Source  dialog select  Machine Data Source  tab and click  new. Picture  2  MySql OBDC Driver 5-        Select  MySQL Connector/ODBC  driver   from list. Click OK.   6-        Specify connection parameters and click OK. 7-        Newly created data source will be added to Machine Data Source tab. Select it and click OK. 8-        Check Mysql DB and Validate that export is successfull.