ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "De Gaetano Giuseppe" <degaet...@PITAGORA.IT>
Subject SqlMapClient multithread applications
Date Fri, 05 Jan 2007 13:23:16 GMT

I am coding a java multithread application.

In my application I have the following object which needs to load the
configuration files from a path not specified in the classpath end build
an SqlMapClient.

The Hashtable is used for:

*         cache the clients and avoid the building of a new SqlMapClient
every time;

*         speed up the application avoiding to load and parse the
different config files every time


public class SqlMapClientConfig {

    private static Hashtable clients;



            clients = new Hashtable();



    private SqlMapClientConfig(){




    public Object clone() throws CloneNotSupportedException {

        throw new CloneNotSupportedException();




    public static SqlMapClient getClient(String db, String usecase,) {

        String key =  db + "." + usecase;

        String path = "/dat/" + db + "/" + usecase;




            return (SqlMapClient) clients.get(key);


            Loader loader = new Loader(path);


            Reader reader = null;

        try {

             reader = Resources.getResourceAsReader (loader,

         } catch (IOException e) {



         SqlMapClient sqlMap = null;


         sqlMap = (SqlMapClient)



         return sqlMap;





If the application is multithread and each thread uses the same client
will I have some problem?

Is the iBatis engine handling the concurrency or should I care?


Is there any best practice?




View raw message