ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Butler" <jeffgbut...@gmail.com>
Subject Re: Invalid Column Type issue in confluence
Date Thu, 27 Apr 2006 03:01:26 GMT
The JDBC type specified in the mapping can only be one of the standard JDBC
types that are listed in java.sql.Types.  Some of the types you are
specifying (VARCHAR2, NUMBER) are invalid - and iBATIS will use
Types.OTHERin those cases.  This is likely that cause of the problem
you are seeing.
Switch to one of the supported datatypes - that will probably solve it.

Jeff Butler


On 4/26/06, Yusuf <Yusuf@ekalife.co.id> wrote:
>
> Hi, regarding the 'invalid column type' problem, I've tried to reproduce
> it :
>
> i made 2 insert statement, one using map as a parameter, another using
> simple pojo class :
>
> <insert id="insertEmp" parameterClass="java.util.HashMap">
>        INSERT INTO EMP ( EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM,
> DEPTNO)
>        VALUES (
>        #empno:NUMBER#,
>        #ename:VARCHAR2#,
>        #job:VARCHAR2#,
>        #mgr:NUMBER#,
>        #hiredate:DATE#,
>        #sal:NUMBER#,
>        #comm:NUMBER#,
>        #deptno:NUMBER#)
> </insert>
>
> <insert id="insertEmp2" parameterClass="sample.Emp">
>        INSERT INTO EMP ( EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM,
> DEPTNO)
>        VALUES (
>        #empno:NUMBER#,
>        #ename:VARCHAR2#,
>        #job:VARCHAR2#,
>        #mgr:NUMBER#,
>        #hiredate:DATE#,
>        #sal:NUMBER#,
>        #comm:NUMBER#,
>        #deptno:NUMBER#)
> </insert>
>
> and then in the java class, i tried the first insert (with map as
> parameter), without setting the value of column COMM :
>
> try {
>        Reader reader =
> Resources.getResourceAsReader("sql-map-config.xml");
>        SqlMapClient sqlMap =
> SqlMapClientBuilder.buildSqlMapClient(reader);
>
>        Map map = new HashMap();
>        map.put("empno", new Integer(1234));
>        map.put("ename", "YUSUF");
>        map.put("job", "ANALYST");
>        map.put("mgr", new Integer(7839));
>        map.put("hiredate", new Date());
>        map.put("sal", new Integer(2000));
>        //map.put("comm", null);
>        map.put("deptno", new Integer(10));
>        sqlMap.insert("insertEmp", map);
>
> }catch(Exception e) {
>        e.printStackTrace();
> }
>
> and also tried the second insert (with class as parameter), also without
> setting the value of column COMM :
>
> try {
>        Reader reader =
> Resources.getResourceAsReader("sql-map-config.xml");
>        SqlMapClient sqlMap =
> SqlMapClientBuilder.buildSqlMapClient(reader);
>
>        Emp emp = new Emp();
>        emp.setEmpno(new Integer(1234));
>        emp.setEname("YUSUF");
>        emp.setJob("ANALYST");
>        emp.setMgr(new Integer(7839));
>        emp.setHiredate(new Date());
>        emp.setSal(new Integer(2000));
>        //emp.setComm()
>        emp.setDeptno(new Integer(10));
>        sqlMap.insert("insertEmp2", emp);
>
> }catch(Exception e) {
>        e.printStackTrace();
> }
>
> and both statements failed to execute with the fist stacktrace like this
> :
>
> com.ibatis.common.jdbc.exception.NestedSQLException:
> --- The error occurred in sample/sql/sql-map.xml.
> --- The error occurred while applying a parameter map.
> --- Check the insertEmp2-InlineParameterMap.
> --- Check the parameter mapping for the 'comm' property.
> --- Cause: java.sql.SQLException: Invalid column type
> Caused by: java.sql.SQLException: Invalid column type
>        at
> com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdat
> e(GeneralStatement.java:87)
>        at
> com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.insert(SqlMapExecut
> orDelegate.java:442)
>        at
> com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.insert(SqlMapSessionImpl
> .java:85)
>        at
> com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.insert(SqlMapClientImpl.j
> ava:57)
>        at
> com.ekalife.mri.sample.SampleServlet.doGet(SampleServlet.java:53)
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>        at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica
> tionFilterChain.java:252)
>        at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt
> erChain.java:173)
>        at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValv
> e.java:214)
>        at
> org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveCo
> ntext.java:104)
>        at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:5
> 20)
>        at
> org.apache.catalina.core.StandardContextValve.invokeInternal(StandardCon
> textValve.java:198)
>        at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValv
> e.java:152)
>        at
> org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveCo
> ntext.java:104)
>        at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:5
> 20)
>        at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java
> :137)
>        at
> org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveCo
> ntext.java:104)
>        at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java
> :118)
>        at
> org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveCo
> ntext.java:102)
>        at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:5
> 20)
>        at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.
> java:109)
>        at
> org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveCo
> ntext.java:104)
>        at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:5
> 20)
>        at
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
>        at
> org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
>        at
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:79
> 9)
>        at
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processC
> onnection(Http11Protocol.java:705)
>        at
> org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:57
> 7)
>        at
> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool
> .java:684)
>        at java.lang.Thread.run(Thread.java:534)
>
> sorry for the rather long message, it's just i'm curious about this
> problem..
> thanks..
> Yusuf.
>
> -----Original Message-----
> From: Nathan Maves [mailto:Nathan.Maves@Sun.COM]
> Sent: Friday, April 21, 2006 10:24 PM
> To: user-java@ibatis.apache.org
> Subject: Re: Invalid Column Type issue in confluence
>
>
> The first option should work fine.  Are you positive that it is not
> one of your other columns causing the issue?
>
> Nathan
>
> On Apr 20, 2006, at 7:21 PM, Yusuf wrote:
>
> > Hi,
> > In the faq page about null value inserts in here:
> > http://opensource.atlassian.com/confluence/oss/display/IBATIS/What
> > +cause
> > s+an+Invalid+column+type+error+with+Oracle
> > said that you can do something like this and you can prevent the
> > misleading error 'Invalid Column Type' if the value in line2 and
> > sold_date is null :
> >
> > <insert id="insertAddress" parameterClass="Address">
> >         INSERT INTO
> >             ADDRESS (
> >               line1,
> >               line2,
> >               city,
> >               state,
> >               postal_code,
> >               purchase_date,
> >               sold_date
> >                 )
> >             values (
> >                       #line1#,
> >               #line2:VARCHAR#,
> >               #city#,
> >               #state#,
> >               #postal_code#,
> >               #purchase_date#,
> >               #sold_date:DATE#
> >             )
> > </insert>
> >
> > But this solution never works for me (or maybe for oracle..),
> > instead i
> > always have to do something like :
> >
> > <insert id="insertAddress" parameterClass="Address">
> >         INSERT INTO
> >             ADDRESS (
> >               line1,
> >               line2,
> >               city,
> >               state,
> >               postal_code,
> >               purchase_date,
> >               sold_date
> >                 )
> >             values (
> >                 #line1#,
> >               <isNull property="line2">
> >                       null,
> >               </isNull>
> >               <isNotNull property="line2">
> >                       #line2#,
> >               </isNotNull>
> >               #city#,
> >               #state#,
> >               #postal_code#,
> >               #purchase_date#,
> >               #sold_date#
> >             )
> > </insert>
> >
> > I was wondering if someone actually having the same problem with me,
> > currently i'm using
> > - iBATIS 2.1.5 build 582
> > - oracle 8.1.7
> > - oracle10g jdbc thin driver (ojdbc14.jar)
> > - c3p0 0.9.0.2
> >
> > Thanks :)
> > Yusuf.
> >
>
>
>

Mime
View raw message