lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "supriya (JIRA)" <j...@apache.org>
Subject [jira] Created: (LUCENE-1273) based on hasmap value the selected items has to come
Date Fri, 25 Apr 2008 13:53:57 GMT
based on hasmap value the selected  items has to come
-----------------------------------------------------

                 Key: LUCENE-1273
                 URL: https://issues.apache.org/jira/browse/LUCENE-1273
             Project: Lucene - Java
          Issue Type: Bug
    Affects Versions: 2.1
         Environment: WindowsXp , java1.4 , ibatis2.1
            Reporter: supriya


Hi to all  . i am new  to this forum

i am implementing ibatis in struts project in that i have to select some fields from database
for that i am written code in struts with out using ibatis 


the code is 





public BooksActionForm retriveBookDetails(BooksActionForm form1) {
 
		DBUtils dbutils = new DBUtils();
 
		BooksActionForm newForm = new BooksActionForm();
		// BooksActionForm newForm = new BooksActionForm ();
		Connection con = null;
		PreparedStatement prpStmt = null;
		ResultSet rs = null;
 
		try {
 
			System.out.println("sorry");
 
			int i = form1.getPrimaryKey();
			
			String sqlQuery = "SELECT bookname,author,available,publisher,category FROM insertadminbook
where bookid=?  ";
 
			System.out.println("the value of primary" + form1.getPrimaryKey());
						con = dbutils.create();
			prpStmt = con.prepareStatement(sqlQuery);
			
			prpStmt.setInt(1, form1.getPrimaryKey());
			
			rs = prpStmt.executeQuery();
 
			
			
			if (rs.next()) {
 
			
				newForm.setBookname(rs.getString(1));
				newForm.setAuthorname(rs.getString(2));
				newForm.setAvailablebooks(rs.getString(3));
				newForm.setPublisher(rs.getString(4));
				newForm.setCategory(rs.getString(5));
 
				// System.out.println(""+rs.getString(1));
				System.out.println("bookdao" + rs.getString(1));
				System.out.println("bookdao" + rs.getString(2));
				System.out.println("bookdao" + rs.getString(3));
				System.out.println("bookdao" + rs.getString(4));
				System.out.println("bookdao" + rs.getString(5));
				System.out.println("sorry6");
 
			}
 
		} catch (SQLException e) {
			System.err
					.println("SQL Exception occured while accessing the table");
			e.printStackTrace();
 
		}
		return newForm;
 
	}




this is worked after implement the ibatis the code is



public IbatisBooksForm retriveBookDetails(IbatisBooksForm form1) {
		
		
		//IbatisLoginForm  form = new IbatisLoginForm();
		
		//Object  bookvalue = new  IbatisBooksForm(primarykey);
		
		IbatisBooksForm  form2 =new IbatisBooksForm();
		
		try{
		   int bookidvalue =form1.getPrimaryKey();
		   
		   
		   IbatisBooksForm form3 = new IbatisBooksForm();
		   form3.setPrimaryKey(bookidvalue);
		   System.out.println("the book id value"+bookidvalue);
		  sqlMap.queryForObject("getAllBookDetails",bookidvalue);
		
	String bookname=	form1.getBookname();
    String authorname=		form1.getAuthorname();
   String availablebooks=		form1.getAvailablebooks();
		String publisher=form1.getPublisher();
		String category=form1.getCategory();
		
	//	IbatisBooksForm  form2 =new IbatisBooksForm();
		
		form2.setBookname(bookname);
		form2.setAuthorname(authorname);
		form2.setAvailablebooks(availablebooks);
		form2.setPublisher(publisher);
		form2.setCategory(category);
		
		}
		
		catch(Exception e)
		{
			System.out.println("the exception is"+e.getMessage());
		}
		
		return form2;
		
	}



in this i am written ibatis sql query gfor selecting some fields based on bookid in sqlMap
like this



<select id="getAllBookDetails"     resultClass="booksform"    cacheModel="categoryCache">
select 
 
BOOKNAME                 as   bookname
 
AUTHORNAME                as  authorname
 
AVAILABLEBOOKS             as  availablebooks
 
PUBLISHER                   as   publisher
 
CATEGORY                    as    category
 
 
 
FROM     IBATISADMINBOOK    where   BOOKID =#bookid#
 
 
</select>




in ibatis action class coding i am not getting that how to place book id value for comparing
the where condition in sql query 


i am getting problem in ibatis action class the coding line is




sqlMap.queryForObject("getAllBookDetails",bookidvalue);



here i am not getting that how to place the bookid value from form bean class 


if any one know solution for this problem plz give me reply 


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


Mime
View raw message