ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Larry Meadors <lmead...@apache.org>
Subject Re: Very new to ibatis -- help required.
Date Thu, 09 Feb 2006 05:20:06 GMT
There are 2 things here that jump out as bad ideas:

 1) Using M$ Access for *anything* Java-related
 2) Hijacking another thread and adding your questions to it

So, I would suggest you get either MySQL or PostregreSQL or...well,
almost ANYTHING would be a better choice than Access (except for maybe
FoxPro...that *might* be worse). You need a JDBC driver that doesn't
totally suck, and the JDBC-ODBC bridge does not meet that criteria.

Next, get the User Guide and READ it. At least skim through it, please.

http://ibatis.apache.org/javadownloads.html

Larry


On 2/8/06, jayalakshmi.mohanarangam@wipro.com
<jayalakshmi.mohanarangam@wipro.com> wrote:
>
>
>
> I am very new to struts and ibatis. I am trying to develop a very small
> application. I just have jsp
> Page (application is developed using struts) which has textbox, which
> gets the id. I want to put the value in the variable id into the
> microsoft access database using ibatis. That's all.
>
> I have downloaded iBATIS_DBL-2.1.7.597 version. I am using jdk1.5.0_06.
> will it be compatible.
> I am working with struts 1.2.7.
>
> I have written two xmls
>  UserForm.xml
>
>   <?xml version="1.0" encoding="ISO-8859-1"?>
>
>
> <!DOCTYPE sqlMap
>   PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN">
>
> <sqlMap namespace="Person">
>
>    <insert id="insertPerson" parameterClass="login.UserForm">
>         INSERT INTO PERSON VALUES(#id#)
>    </insert>
>
> </sqlMap>
>
>
> sqlMap.xml
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
>
> <sqlMapConfig>
>
> <transactionManager type="JDBC">
>
> <dataSource type="SIMPLE"
> <property name="JDBC.Driver" value="sun.jdbc.odbc.JdbcOdbcDriver")/>
> <property name="JDBC.ConnectionURL" value="Jdbc:Odbc:dsn"/>
> <property name="JDBC.Username" value="jaya"/>
> <property name="JDBC.Password" value="lakshmi")/>
> </dataSource>
>
> </transactionManger>
>
>
> </sqlMapConfig>
>
>
>
>
>
> I have Person table with id column.
>
> Can anyone tell me where I should extract the ibatis, where should I put
> the person.xml and sqlmap.xml;
>
> Regards,
> Jayalakshmi.
>
>
>
>
>
>
>
>
>
>
>
>
>
> -----Original Message-----
> From: Yusuf [mailto:Yusuf@ekalife.co.id]
> Sent: Thursday, February 09, 2006 8:40 AM
> To: user-java@ibatis.apache.org
> Subject: RE: Different Number of Columns in resultClass with xml and
> with HashMap
>
> Hello, regarding my last question, let me simplify this question:
> I have a resultMap that contains another select statement that populates
> one of the column, If the resultMap contains 10 column, which 2 of them
> contains another select statement, then this is what happens:
>         - if i map the results to a Map or a class, then the result is
> correct (10 columns)
>         - if i use resultMap="xml", then the result is only 8 columns
> (without the 2 which contains another select)
>
> have anyone experienced this before? or a bug?
>
> Thanks,
> Yusuf.
>
> -----Original Message-----
> From: Yusuf
> Sent: Tuesday, February 07, 2006 2:02 PM
> To: user-java@ibatis.apache.org
> Subject: Different Number of Columns in resultClass with xml and with
> HashMap
>
>
> Hi,
> I have a working query and the resultmap is like this:
>
> <resultMap id="resultParent" class="java.util.HashMap">
>         <result property="NAMA_PP" column="NAMA_PP" javaType="string"
> jdbcType="VARCHAR2" nullValue=""/>
>         <result property="BEGDATE" column="BEGDATE" javaType="string"
> jdbcType="VARCHAR2" nullValue=""/>
>         <result property="ENDDATE" column="ENDDATE" javaType="string"
> jdbcType="VARCHAR2" nullValue=""/>
>         <result property="SAR_POLIS" column="{spaj=REG_SPAJ,
> tahunKe=TAHUN_KE}" javaType="double" jdbcType="NUMBER" nullValue="0"
> select="selectChild1"/>
>         <result property="MSPR_PREMIUM" column="MSPR_PREMIUM"
> javaType="double" jdbcType="NUMBER" nullValue="0"/>
>
>         <result property="PREMI_RIDER" column="REG_SPAJ"
> javaType="double" jdbcType="NUMBER" nullValue="0"
> select="selectChild2"/>
>         <result property="PREMI_EXTRA" column="REG_SPAJ"
> javaType="double" jdbcType="NUMBER" nullValue="0"
> select="selectChild3"/>
> </resultMap>
>
> So far there is no problem (all the inner fields also populated with the
> selectChild1, selectChild2, ..),
> but when i tried changing the resultMap class to xml like this:
>
> <resultMap id="resultParent" class="xml">
>         <result property="NAMA_PP" column="NAMA_PP" javaType="string"
> jdbcType="VARCHAR2" nullValue=""/>
>         <result property="BEGDATE" column="BEGDATE" javaType="string"
> jdbcType="VARCHAR2" nullValue=""/>
>         <result property="ENDDATE" column="ENDDATE" javaType="string"
> jdbcType="VARCHAR2" nullValue=""/>
>         <result property="SAR_POLIS" column="{spaj=REG_SPAJ,
> tahunKe=TAHUN_KE}" javaType="double" jdbcType="NUMBER" nullValue="0"
> select="selectChild1"/>
>         <result property="MSPR_PREMIUM" column="MSPR_PREMIUM"
> javaType="double" jdbcType="NUMBER" nullValue="0"/>
>
>         <result property="PREMI_RIDER" column="REG_SPAJ"
> javaType="double" jdbcType="NUMBER" nullValue="0"
> select="selectChild2"/>
>         <result property="PREMI_EXTRA" column="REG_SPAJ"
> javaType="double" jdbcType="NUMBER" nullValue="0"
> select="selectChild3"/>
> </resultMap>
>
> and used a custom type handler to process the xml like this (i'm using
> dom4j):
>
> static class XmlRowHandler implements RowHandler {
>         private Document domDocument;
>         public XmlRowHandler(String xmlResultName) {
>                 domDocument = DocumentHelper.createDocument();
>                 getDomDocument().addElement(xmlResultName);
>         }
>         public void handleRow(Object object) {
>                 try {
>                         Document xmlFragment = DocumentHelper
>                                         .parseText((String) object);
>                         Element xmlElement =
> xmlFragment.getRootElement();
>
> getDomDocument().getRootElement().add(xmlElement);
>                 } catch (DocumentException e) {
>                 }
>         }
>         public Document getDomDocument() {
>                 return domDocument;
>         }
> }
>
> private Document queryXml(String queryId, Object param) {
>         RowHandler rowHandler = new XmlRowHandler("result");
>         getSqlMapClientTemplate().queryWithRowHandler(queryId, param,
> rowHandler);
>         Document doc = ((XmlRowHandler) rowHandler).getDomDocument();
>         return doc;
> }
>
> the result is different. Only the columns without inner selects are
> shown, so instead of having 7 columns per row, there is only 4 columns
> per row. I have used this custom xml handler for other queries and it
> ran well.
>
> Is this a bug in ibatis, or I've done something wrong?
>
> Thank you for your help and regards,
> Yusuf S.
>
>
>
>
> The information contained in this electronic message and any attachments to this message
are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential
or privileged information. If you are not the intended recipient, you should not disseminate,
distribute or copy this e-mail. Please notify the sender immediately and destroy all copies
of this message and any attachments.
>
> WARNING: Computer viruses can be transmitted via email. The recipient should check this
email and any attachments for the presence of viruses. The company accepts no liability for
any damage caused by any virus transmitted by this email.
>
> www.wipro.com
>

Mime
View raw message