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: dynamic sql map
Date Wed, 11 Jan 2006 18:02:53 GMT
You need to get your SQL logging working - search the archives to get
that working.

The problem you are having are not iBATIS issues, they are because the
SQL that you are building is broken.

Get your logging working, and the resolution will be apparent.

Larry


On 1/11/06, Henry Lu <zhlu@umich.edu> wrote:
> I made changes and it worked! But now I made more changes and it broken
> again:
>
> org.springframework.jdbc.BadSqlGrammarException: Bad SQL grammar [] in
> task 'SqlMapClient operation'; nested exception is
> com.ibatis.common.jdbc.exception.NestedSQLException: --- The error
> occurred while applying a parameter map. --- Check the
> select_list-InlineParameterMap. --- Check the statement (query failed).
> --- Cause: java.sql.SQLException: ORA-00933: SQL command not properly ended
>
>   <statement id="select_list"
>              resultClass="domain.NameValue">
>     select $col_code$ as m_name,
>            $col_descr$ as m_value
>            FROM $table_name$
>     <isNotNull prepend="and" property="where_order_str">
>         $where_order_str$
>     </isNotNull>
>   </statement>
>
>       Map map = new HashMap(4);
>       map.put("col_code", "STATE_ABBRV");
>       map.put("col_descr", "STATE");
>       map.put("table_name", "USSTATE_DESC");
>       map.put("where_order_str",
>          "ORDER BY STATE");
>
>       return getSqlMapClientTemplate().queryForList(
>                "select_list", map);
>
> -Henry
>
> Ben Munat wrote:
>
> > If you're using commons logging (and you should be), you can set
> > logging for "java.sql" to debug (in the properties file version:
> > "log4j.logger.java.sql=DEBUG"). This will print all the generated SQL,
> > along with parameters and result sets, in your log.
> >
> > Also, it looks like the error message says you've got a "[]" in your
> > sql... that might be a clue. Hmm, and I think you need to tell ibatis
> > that the input to the statement is a map (add a 'parameterClass="map"'
> > attribute to your statement element).
> >
> > Hope that helps...
> >
> > b
> >
> > Henry Lu wrote:
> >
> >> I got errors:
> >>
> >> org.springframework.jdbc.BadSqlGrammarException: Bad SQL grammar []
> >> in task 'SqlMapClient operation'; nested exception is
> >> com.ibatis.common.jdbc.exception.NestedSQLException: --- The error
> >> occurred in edu/umich/med/umms/coreyp/dao/ibatis_map/misc.xml. ---
> >> The error occurred while applying a parameter map. --- Check the
> >> select_list-InlineParameterMap. --- Check the statement (query
> >> failed). --- Cause: java.sql.SQLException: ORA-00942: table or view
> >> does not exist
> >> org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator
> >>
> >> with the sql:
> >>
> >>  <statement id="select_list"
> >>             resultClass="domain.NameValue">
> >>    select $col_code$ as m_name,
> >>           $col_descr$ as m_value
> >>           FROM $my_table_name$
> >>  </statement>
> >>
> >> and java code:
> >>
> >>      Map map = new HashMap(4);
> >>      map.put("col_code", "STATE_ABBRV");
> >>      map.put("col_descr", "STATE");
> >>      map.put("my_table_name", "USSTATE_DESC");
> >>      map.put("where_order_str",
> >>         "ORDER BY STATE");
> >>          return getSqlMapClientTemplate().queryForList(
> >>               "select_list", map);
> >>
> >> Is there anyone can help me out this?
> >>
> >> -Henry
> >>
> >>
> >>
> >>
> >> Larry Meadors wrote:
> >>
> >>> Vector myVector = new Vector(theList);
> >>>
> >>> Larry
> >>>
> >>> On 1/11/06, Ashish Kulkarni <kulkarni_ash1312@yahoo.com> wrote:
> >>>
> >>>
> >>>> Hi
> >>>> I have defined a query as
> >>>> <select id="selectLinesFromView"
> >>>> resultClass="java.lang.String">
> >>>> SELECT L083LINE FROM PL1083 WHERE L083CODE = #value#
> >>>> ORDER BY L083SQNO
> >>>> </select>
> >>>>
> >>>> and in my java code i do
> >>>> List list = client.queryForList("selectLinesFromView",
> >>>> "ABC");
> >>>>
> >>>> Suppose if i want a Vector as output, i just cannot
> >>>> parse it as it gives me classcastexception,
> >>>> so what is a best way of getting Vector as output, or
> >>>> do i have to iterate through list and uild my own
> >>>> vector
> >>>>
> >>>>
> >>>> Ashish
> >>>>
> >>>>
> >>>>
> >>>> A$HI$H
> >>>>
> >>>> __________________________________________________
> >>>> Do You Yahoo!?
> >>>> Tired of spam?  Yahoo! Mail has the best spam protection around
> >>>> http://mail.yahoo.com
> >>>>
> >>>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >
> >
>

Mime
View raw message