You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Ashish Kulkarni <as...@gmail.com> on 2008/10/23 21:42:52 UTC

Issue with creating SqlMapClient using Properties object

HiI am trying to create SqlMapClient using Properties object
I am getting following error, please see my code below

Exception in thread "main" java.lang.NullPointerException
at
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.endTransaction(SqlMapExecutorDelegate.java:782)
at
com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.endTransaction(SqlMapSessionImpl.java:176)
at
com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.endTransaction(SqlMapClientImpl.java:154)
at
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.autoEndTransaction(SqlMapExecutorDelegate.java:883)
at
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:622)
at
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:589)
at
com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessionImpl.java:118)
at
com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForList(SqlMapClientImpl.java:95)

        Properties prop = new Properties();
        prop.setProperty("url",
"jdbc:as400:myas400/EXTDB6301;naming=system;date format=iso;time
format=hms;prompt=false");
        prop.setProperty("driver", "com.ibm.as400.access.AS400JDBCDriver");
        prop.setProperty("username", "userid");
        prop.setProperty("password", "password");

        String resource = "com/ashishk/test/sql/SQLMapConfigWeb.xml";
        Reader reader = Resources.getResourceAsReader(resource);

        SqlMapClient sqlMapClient =
SqlMapClientBuilder.buildSqlMapClient(reader, prop);

        Map map = new Hashtable();
map.put("SYSTEM", "system");
map.put("AS400USER", "user");
map.put("ENVNAME", "MAPS6305F3");
map.put("P204PORD", 10000122);
        List poDataList =  sqlMapClient.queryForList("getPOData",map);

My SQLMapConfigWeb.xml is as below

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sqlMapConfig
PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-config-2.dtd">
<sqlMapConfig>
    <sqlMap resource="com/ashishk/test/sql/PODataExternalTable.xml" />
 </sqlMapConfig>

What may be issue, when i create SqlMapClient using Properties file, it
works, but for some reason when i use Properties object i dont get
connection

Ash