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 HelpMePlz <su...@gmail.com> on 2008/04/28 10:43:53 UTC

how can we send formbean bookid value to update statement

Hi to All



         public void updateInfo(IbatisBooksForm form) {


		int i = 0;

		try {
			
			int bookid=form.getPrimaryKey();
			
			HashMap map = new HashMap();
			  
			  map.put("bookid",new Integer(form.getPrimaryKey()));
			  
			  System.out.println("the bookid value"+bookid);
			
			 // sqlMap.queryForPaginatedList("updateAccount",new
Integer(form.getPrimaryKey()),map);
			  
sqlMap.queryForList("updateAccount",new Integer(form.getPrimaryKey()) );
			System.out.print("the ibatis program 7");
			
			String author = form.getAuthorname();

			String bookname = form.getBookname();

			String available = form.getAvailablebooks();

			String publisher = form.getPublisher();

			String category = form.getCategory();
			
			
			form.setBookname(bookname);
			form.setAuthorname(author);
			form.setAvailablebooks(available);
			form.setPublisher(publisher);
			form.setCategory(category);
		//	form.setPrimaryKey(form.getPrimaryKey());

			
			
		i = sqlMap.update("updateAccount",form );

		} catch (SQLException e) {


		e.printStackTrace();

		
		}

		

		}


For this sql query is

<update id="updateAccount"  parameterClass="booksform">


update IBATISADMINBOOK set BOOKNAME = #bookname#,

AUTHORNAME  =#authorname#,

AVAILABLEBOOKS=#availablebooks#,

PUBLISHER=#publisher#,

CATEGORY=#category#


 where BOOKID =?

</update>


<parameterMap id="update"   class="java.util.HashMap">
  
  
 <parameter property="bookid"  jdbcType="NUMBER"
 
            javaType="java.lang.Integer"  mode="IN" />

</parameterMap>


here i am not getting that how to pass bookid value to update statement

i am getting error like this

the ibatis program 7com.ibatis.common.jdbc.exception.NestedSQLException:   
--- The error occurred in SqlMap.xml.  
--- The error occurred while applying a parameter map.  
--- Check the updateAccount-InlineParameterMap.  
--- Check the statement (update failed).  
--- Cause: java.sql.SQLException: ORA-01008: not all variables bound


if any one know solution for this problem plz send me  reply
-- 
View this message in context: http://www.nabble.com/how-can-we-send-formbean-bookid-value-to-update-statement-tp16930962p16930962.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Re: how can we send formbean bookid value to update statement

Posted by Nathan Maves <na...@gmail.com>.
I would start by reading the developers guide.
The root of your issue is that you seem to completely confussed about how to
use ibatis.  You have both #var# and ? in your update sql map.  Along with
only sending one parameter when you updated is expecting 6.

Start from the begin and read the documentation.

Nathan

On Mon, Apr 28, 2008 at 2:43 AM, HelpMePlz <su...@gmail.com>
wrote:

>
> Hi to All
>
>
>
>         public void updateInfo(IbatisBooksForm form) {
>
>
>                int i = 0;
>
>                try {
>
>                        int bookid=form.getPrimaryKey();
>
>                        HashMap map = new HashMap();
>
>                          map.put("bookid",new
> Integer(form.getPrimaryKey()));
>
>                          System.out.println("the bookid value"+bookid);
>
>                         //
> sqlMap.queryForPaginatedList("updateAccount",new
> Integer(form.getPrimaryKey()),map);
>
> sqlMap.queryForList("updateAccount",new Integer(form.getPrimaryKey()) );
>                        System.out.print("the ibatis program 7");
>
>                        String author = form.getAuthorname();
>
>                        String bookname = form.getBookname();
>
>                        String available = form.getAvailablebooks();
>
>                        String publisher = form.getPublisher();
>
>                        String category = form.getCategory();
>
>
>                        form.setBookname(bookname);
>                        form.setAuthorname(author);
>                        form.setAvailablebooks(available);
>                        form.setPublisher(publisher);
>                        form.setCategory(category);
>                //      form.setPrimaryKey(form.getPrimaryKey());
>
>
>
>                i = sqlMap.update("updateAccount",form );
>
>                } catch (SQLException e) {
>
>
>                e.printStackTrace();
>
>
>                }
>
>
>
>                }
>
>
> For this sql query is
>
> <update id="updateAccount"  parameterClass="booksform">
>
>
> update IBATISADMINBOOK set BOOKNAME = #bookname#,
>
> AUTHORNAME  =#authorname#,
>
> AVAILABLEBOOKS=#availablebooks#,
>
> PUBLISHER=#publisher#,
>
> CATEGORY=#category#
>
>
>  where BOOKID =?
>
> </update>
>
>
> <parameterMap id="update"   class="java.util.HashMap">
>
>
>  <parameter property="bookid"  jdbcType="NUMBER"
>
>            javaType="java.lang.Integer"  mode="IN" />
>
> </parameterMap>
>
>
> here i am not getting that how to pass bookid value to update statement
>
> i am getting error like this
>
> the ibatis program 7com.ibatis.common.jdbc.exception.NestedSQLException:
> --- The error occurred in SqlMap.xml.
> --- The error occurred while applying a parameter map.
> --- Check the updateAccount-InlineParameterMap.
> --- Check the statement (update failed).
> --- Cause: java.sql.SQLException: ORA-01008: not all variables bound
>
>
> if any one know solution for this problem plz send me  reply
> --
> View this message in context:
> http://www.nabble.com/how-can-we-send-formbean-bookid-value-to-update-statement-tp16930962p16930962.html
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>