Showing posts with label Reading Arabic Data from MS Access Database. Show all posts
Showing posts with label Reading Arabic Data from MS Access Database. Show all posts

Wednesday, June 11, 2014

Reading Arabic Data from MS Access Database

Reading Arabic Data from MS Access Database 


Reading and writing data to/from Ms Access Database can be done using JDBC , Hibernate etc frameworks.

Problem: I had a requirement of reading arabic data from ms access database. We tried using hibernate , jdbc .Reading other  than arabic data could be read easily done using hibernate and jdbc .
But for reading Arabic Data is difficult in JDBC and Hibernate . It mostly gives ????? for Arabic data.That means for UTF-8 it was not possible for me . So we went for JACKCESS.

We could use  JACKCESS to read Arabic data for MS Access Database. 



Jackcess is a pure Java library for reading and writing MS Access databases. It provides a robust, cross-platform backend API allowing other developers to integrate MS Access support into their Java applications



Create a  dynamic web project in java.

Download Following Jars :



Put the above jars in your lib folder.

Create a database in microsoft acces with following detail.


Say  a database Name TestDatabase and in it a

table name user .


I have three columns id , name and age .



Now to access the data i have the following code sample :

package com.MSaccessArabicData;

import java.io.File;
import java.util.Map;
import com.healthmarketscience.jackcess.Database;
import com.healthmarketscience.jackcess.Table;
public class MsDatabaseAccess {
 public static void main(String[] args) {
  try {
   Table table = Database
     .open(new File(
       "D:\\TestDatabase.mdb"))
     .getTable("user");
   for (Map row : table) {

    String name = (String) row.get("name");

    int age = (Integer) row.get("age");
    
   }

  } catch (Exception e) {
   e.printStackTrace();
  }
 }
}




Documentation for jackcess is available here.