ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cuong PN <pncuon...@yahoo.com>
Subject Re: iBatis configuration problem
Date Thu, 29 May 2008 01:54:13 GMT

Hi Jeff

Thanks a lot! It works perfectly now. I think I tried that before but
previously somehow it didn't work either. I might've messed up something
else while I did sqlMapConfig -> sqlMap.

Just another question, because the developer guide coming along with iBatis
package said in <sqlmap resource="..." /> we can put either a sqlMap file or
a sqlMap Config file:

"The sqlMap element is used to explicitly include an SQL Map or another SQL
Map Configuration file."

Was it a mistake saying so? Because that's why i decided to do something
different =D Thanks!



Jeff Butler-2 wrote:
> 
> You have sqlMapConfig->sqlMapConfig->sqlMap.  This is not correct.
> 
> Delete sqlMapCollection.xml.  Reference tts_user.xml directly in
> sqlMapConfig.xml.
> 
> Jeff Butler
> 
> On Wed, May 28, 2008 at 10:57 AM, cuong PN <pncuong83@yahoo.com> wrote:
> 
>>
>> Hi guys
>>
>> I've been looking at this, searching the Internet, trying this and that
>> but
>> nothing works yet. I'd greatly appreciate any help to resolve this.
>> Thanks
>> so so much!
>>
>> When I run, I got this error:
>>
>> com.ibatis.sqlmap.client.SqlMapException: There is no statement named
>> TTS_USER.countUsers in this SqlMap.
>>
>> Even though after searching thru the net, I think my configuration looks
>> right, at least the namespace part. Or am I wrong? Funny thing is even if
>> I
>> messed up the xml format of sqlmap file (like doing "</sqlMap----- #>"
>> instead of a correct closing tag "</sqlMap>), nothing is complained
>> about.
>> Looks like SQLMaps isn't even reading that sqlmap file. Please kindly see
>> details below:
>>
>> ---- sqlMapConfig.xml ------
>> <?xml version="1.0" encoding="UTF-8" ?>
>> <!DOCTYPE sqlMapConfig PUBLIC "-//ibatis.apache.org//DTD SQL Map Config
>> 2.0//EN"
>> "http://ibatis.apache.org/dtd/sql-map-config-2.dtd">
>>
>> <sqlMapConfig>
>>
>> <properties resource="appSqlMapConfig.properties" />
>>
>> <settings
>>    useStatementNamespaces="true"
>> />
>>
>> <transactionManager type="JDBC" >
>>    <dataSource type="JNDI">
>>        <property name="DataSource" value="${appJNDI}"/>
>>    </dataSource>
>> </transactionManager>
>>
>> <sqlMap resource="sqlMapCollection.xml" />
>> </sqlMapConfig>
>>
>> ----  End of sqlMapConfig.xml ------
>>
>>
>> ---- sqlMapCollection.xml ------
>> <?xml version="1.0" encoding="UTF-8" ?>
>> <!DOCTYPE sqlMapConfig PUBLIC "-//ibatis.apache.org//DTD SQL Map Config
>> 2.0//EN"
>>                "http://ibatis.apache.org/dtd/sql-map-config-2.dtd">
>>
>> <sqlMapConfig>
>>    <sqlMap resource="sqlmap/sql/tts_user.xml" />
>> </sqlMapConfig>
>>
>> ---- End of sqlMapCollection.xml ------
>>
>>
>> ---- tts_user.xml ----
>> <?xml version="1.0" encoding="UTF-8" ?>
>> <!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
>> "http://ibatis.apache.org/dtd/sql-map-2.dtd">
>>
>> <sqlMap namespace="TTS_USER">
>>    <select id="countUsers" resultClass="Integer">
>>        select count(*) from users
>>    </select>
>> </sqlMap>
>> ---- End of tts_user.xml ----
>>
>> And here's how I configure SQLMaps from java file:
>>
>>            private static Reader reader;
>>            private static String sqlMapConfigResource =
>> "location/to/config/file";
>>
>>            ...
>>            reader = Resources.getResourceAsReader(sqlMapConfigResource);
>>            sqlMapper = SqlMapClientBuilder.buildSqlMapClient(reader);
>>            List resultList =
>> sqlMapper.queryForList("TTS_USER.countUsers");
>>            logger.debug(resultList);
>>            reader.close();
>>
>> Hope to hear from your reply soon! Thanks again!
>> --
>> View this message in context:
>> http://www.nabble.com/iBatis-configuration-problem-tp17516022p17516022.html
>> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/iBatis-configuration-problem-tp17516022p17525767.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Mime
View raw message