Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

ibatis servlet query

servlet

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1 mutago

mutago

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 478 posts

Posted 02 January 2013 - 07:36 PM

I tried querying database records using pass variable from ibatis servlets
it works fine and fetch the records if correct pass value is entered but return error message if wrong pass value is entered
using if statement.
eg


<?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="Display1">
 
<!--- quer data  -->
 <select id="getAll"  parameterClass="long" resultClass="Display1">
   select * from account
WHERE pass ='vatri'

</select>
</sqlMap>






Display1.java

contains getters and setters






ibatis servlet Display2.java

String pass = request.getParameter("pass");

  try {






    Reader reader = Resources.getResourceAsReader("sqlMapConfig.xml");
    SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);


Display1 log1 = new Display1();
long contactId=1;
 log1.setPass1(pass1);

List<Display1> records = (List<Display1>)
  sqlMap.queryForList("Display1.getAll",contactId);
 
  for (Display1 k : records) {
 
  log1 = k;

//use if statement to print records here
//use if statement also to print error
}

}
catch(Exception e){
System.out.println(e);
}




okay now i tried to fetch the record using form inputs from jsp via pass variable, it keeps on returning
error message irrespective of whether correct pass is entered or not.
it seems that Display2.java is no seeing the pass variable from Jsp form.

can u tell me what is wrong in the Display2.java
thanks

please the variable is pass not pass1

when i used input form my query becomes

select * from account
WHERE pass = #pass#


any help please

#2 mutago

mutago

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 478 posts

Posted 02 January 2013 - 09:07 PM

i also try this but is not working
select * from account
WHERE pass = #pass:VARCHAR#


any help

#3 mutago

mutago

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 478 posts

Posted 04 January 2013 - 10:25 AM

problem resolved




Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download