Не сте регистриран!
Регистрирайте се БЕЗПЛАТНО, за да използвате услугите на сайта!
Моля Ви помогнете малко ми липсва това да тръгне
Публикувано на: 26.06.2008 21:52
Чирак
Мнения: (2)
Здравейте на всички които се поинтересувахте от това което пише. Ще се опитам да обясня накратко и ще съм Ви благодарна ако ми помогнете. Значи идеята е посредством JSP and Servlets да се направят 2 drop down boxes за следното: те представляват цени на коли (от - до), по тях потребителя ще търси автомобил. Понеже не искам да използвам JavaScript съм сложила submit button след втория box. Ето какво съм написала като код:
JSP:
CODE 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
< div align = " left " style = " border-color: white " style = " text-align: center " >
< form action = " Search " >
Choose a Price for car :
< select name = " upprice " >
< option value = " 1 " > 40 000 lv .</ option >
< option value = " 2 " > 100 000 lv .</ option >
< option value = " 3 " > 200 000 lv .</ option >
< option value = " 4 " > 300 000 lv .</ option >
< option value = " 5 " > 400 000 lv . </ option >
</ select >
and
<select name = " downprice " >
< option value = " 1 " > 100 000 lv .</ option >
< option value = " 2 " > 200 000 lv .</ option >
< option value = " 3 " > 300 000 lv .</ option >
< option value = " 4 " > 400 000 lv .</ option >
< option value = " 5 " > 550 000 lv .</ option >
</ select >
< input type = " submit " value = " Search " >
</ form >
</ div >
< br >
Servlet:
CODE 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
public class Search extends javax . servlet . http . HttpServlet implements javax . servlet . Servlet {
static final long serialVersionUID = 1 L ;
protected void doGet ( HttpServletRequest request , HttpServletResponse response ) throws ServletException , IOException {
String uppr = request . getParameter ( " upprice " ) ;
Integer upprice = Integer . parseInt ( uppr ) ;
String downpr = request . getParameter ( " downprice " ) ;
Integer downprice = Integer . parseInt ( downpr ) ;
Session hibSession = HibernateUtils . startSession () ;
List < Car > price = AccessCars . getAllCars ( hibSession , upprice , downprice ) ;
hibSession . flush () ;
hibSession . close () ;
HttpSession session = request . getSession () ;
session . setAttribute ( " price " , price ) ;
response . sendRedirect ( " Search.jsp " ) ;
}
}
HQL:
CODE 1
2
3
4
5
6
public static List < Car > getAllCars ( Session hibSession , Integer upprice , Integer downprice ) {
Query qu ery = hibSession.createQ u ery ( " from Car c where price between (c.upprice = :upprice) and (c.downprice = :downprice) " ) ;
qu ery.setInteger(" u pprice " , upprice);
query.setInteger( " downprice " , downprice);
return (List<Car>) query.list();
}
Всичко съм направила чрез Еclipse, Hibernate, Tomcat 6.0.14. За база данни ползвам MySQL. Ето обаче каква грешка ми излиза в сървъра:
CODE 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request .
exception
org . hibernate . hql . ast . QuerySyntaxException : unexpected AST node : = near line 1 , column 52 [ from entities . Car c where price between ( c . upprice = : upprice ) and ( c . downprice = : downprice )]
org . hibernate . hql . ast . ErrorCounter . throwQueryException ( ErrorCounter . java : 59 )
org . hibernate . hql . ast . QueryTranslatorImpl . analyze ( QueryTranslatorImpl . java : 225 )
org . hibernate . hql . ast . QueryTranslatorImpl . doCompile ( QueryTranslatorImpl . java : 158 )
org . hibernate . hql . ast . QueryTranslatorImpl . compile ( QueryTranslatorImpl . java : 109 )
org . hibernate . engine . qu ery.HQLQ u eryPlan .< init > ( HQLQueryPlan . java : 75 )
org . hibernate . engine . qu ery.HQLQ u eryPlan .< init > ( HQLQueryPlan . java : 54 )
org . hibernate . engine . qu ery.Q u eryPlanCache . getHQLQueryPlan ( QueryPlanCache . java : 71 )
org . hibernate . impl . AbstractSessionImpl . getHQLQueryPlan ( AbstractSessionImpl . java : 133 )
org . hibernate . impl . AbstractSessionImpl . createQuery ( AbstractSessionImpl . java : 112 )
org . hibernate . impl . SessionImpl . createQuery ( SessionImpl . java : 1583 )
access . AccessCars . getAllCars ( AccessCars . java : 12 )
servlets . Search . doGet ( Search . java : 23 )
javax . servlet . http . HttpServlet . service ( HttpServlet . java : 690 )
javax . servlet . http . HttpServlet . service ( HttpServlet . java : 803 )
root cause
< AST >: 1 : 52 : unexpected AST node : =
org . hibernate . hql . antlr . HqlSqlBaseWalker . exprOrSubquery ( HqlSqlBaseWalker . java : 4114 )
org . hibernate . hql . antlr . HqlSqlBaseWalker . comparisonExpr ( HqlSqlBaseWalker . java : 3781 )
org . hibernate . hql . antlr . HqlSqlBaseWalker . logicalExpr ( HqlSqlBaseWalker . java : 1758 )
org . hibernate . hql . antlr . HqlSqlBaseWalker . whereClause ( HqlSqlBaseWalker . java : 776 )
org . hibernate . hql . antlr . HqlSqlBaseWalker . qu ery(HqlSqlBaseWalker.java:577)
org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)
org.hibernate.hql.ast.Q u eryTranslatorImpl . analyze ( QueryTranslatorImpl . java : 218 )
org . hibernate . hql . ast . QueryTranslatorImpl . doCompile ( QueryTranslatorImpl . java : 158 )
org . hibernate . hql . ast . QueryTranslatorImpl . compile ( QueryTranslatorImpl . java : 109 )
org . hibernate . engine . qu ery.HQLQ u eryPlan .< init > ( HQLQueryPlan . java : 75 )
org . hibernate . engine . qu ery.HQLQ u eryPlan .< init > ( HQLQueryPlan . java : 54 )
org . hibernate . engine . qu ery.Q u eryPlanCache . getHQLQueryPlan ( QueryPlanCache . java : 71 )
org . hibernate . impl . AbstractSessionImpl . getHQLQueryPlan ( AbstractSessionImpl . java : 133 )
org . hibernate . impl . AbstractSessionImpl . createQuery ( AbstractSessionImpl . java : 112 )
org . hibernate . impl . SessionImpl . createQuery ( SessionImpl . java : 1583 )
access . AccessCars . getAllCars ( AccessCars . java : 12 )
servlets . Search . doGet ( Search . java : 23 )
javax . servlet . http . HttpServlet . service ( HttpServlet . java : 690 )
javax . servlet . http . HttpServlet . service ( HttpServlet . java : 803 )
Това мнение е редактирано от cat_paw на 27.06.2008 10:09
Публикувано на: 27.06.2008 00:39
Ронин
Мнения: (192)
нали знаеш че линк-овете към картинките са
e:\box.bmp
e:\error.bmp
Публикувано на: 27.06.2008 10:11
Чирак
Мнения: (2)
Извинявам се за картинките, сега ги оправих.
1 посетител чете тази тема (0 потребители и 1 гост)
Активни потребители:
---
Още по темата:
php форум ,
flash форум ,
html форум ,
it форум ,
seo форум ,
vista форум ,
pc форум ,
css форум ,
java форум ,
mysql форум ,
дизайн форум