jsp中查询语句的问题
报错在50说我有语法错误:百思不得其解=口=checkthemanualthatcorrespondstoyourMySQLserverversionfortherigh...
报错在50 说我有语法错误: 百思不得其解 =口=
check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
--------------代码如下------
String sql = "select * from book where";
String where = "";
for(int i=0;i <= 3 && !keyword[i].equals("");i++){
if(i != 0){
where+=andor[i-1];
}
where+=" "+condition[i]+" like '%"+keyword[i]+"%'";
}
sql+=where;
....链接数据库 中间略 已经检测 无误....
49 Statement stmt = conn.createStatement();
50 ResultSet rs = stmt.executeQuery(sql);
keyword[i]是存放查询属性的字符串数组,andor[i]是存放逻辑连接词 and or的字符串数组
以下是我接受输入的语句:然后存放到searchBookAdvancedStep2.jsp的那几个字符串数组里
<form method="post" action="searchBookAdvancedStep2.jsp">
<select name = "condition1">
<option value = "isbn" selected> 书号 </option>
<option value = "title"> 书名</option>
<option value = "authors"> 作者 </option>
<option value = "press" > 出版社 </option>
<option value = "pubdate" > 出版日期 </option>
<option value = "sid" > 索书号</option>
</select>
<input type="text" name="keyword1" >
<select name = "andor1">
<option value = "and" selected> and </option>
<option value = "or">or</option>
</select> 展开
check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
--------------代码如下------
String sql = "select * from book where";
String where = "";
for(int i=0;i <= 3 && !keyword[i].equals("");i++){
if(i != 0){
where+=andor[i-1];
}
where+=" "+condition[i]+" like '%"+keyword[i]+"%'";
}
sql+=where;
....链接数据库 中间略 已经检测 无误....
49 Statement stmt = conn.createStatement();
50 ResultSet rs = stmt.executeQuery(sql);
keyword[i]是存放查询属性的字符串数组,andor[i]是存放逻辑连接词 and or的字符串数组
以下是我接受输入的语句:然后存放到searchBookAdvancedStep2.jsp的那几个字符串数组里
<form method="post" action="searchBookAdvancedStep2.jsp">
<select name = "condition1">
<option value = "isbn" selected> 书号 </option>
<option value = "title"> 书名</option>
<option value = "authors"> 作者 </option>
<option value = "press" > 出版社 </option>
<option value = "pubdate" > 出版日期 </option>
<option value = "sid" > 索书号</option>
</select>
<input type="text" name="keyword1" >
<select name = "andor1">
<option value = "and" selected> and </option>
<option value = "or">or</option>
</select> 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询