jsp数据库查询问题出错

[Err]1064-YouhaveanerrorinyourSQLsyntax;checkthemanualthatcorrespondstoyourMySQLserve... [Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'BETWEEN 2 AND 5' at line 3 展开
 我来答
匿名用户
2015-10-05
展开全部
<%
request.setCharacterEncoding("GBK");
String wareno = request.getParameter("wareno");
String amount1 = request.getParameter("amount1");
//int amount1=Integer.parseInt(A_amount1);

Connection conn = null;
Statement stmt = null;
ResultSet rs=null;
String url = "jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=chaoshi";
String loginname = "sa";
String password = "sa";
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
conn = DriverManager.getConnection(url, loginname, password);

String sql1 = "select * from wareinfo where wareinfo.wareno ='"+wareno+"'";
stmt = conn.createStatement();
rs = stmt.executeQuery(sql1);

String sql2 = "insert into buylist (wareno,warename,price,amount1) values(" + rs.getString(1) + "," + rs.getString(2) + "," + rs.getString(4) + "," + amount1 + ")";
stmt.executeUpdate(sql2);

String sql3 = "select * from buylist where buylist.wareno ='"+wareno+"'";
stmt = conn.createStatement();
rs = stmt.executeQuery(sql3);
%>
追问
我之前查到是语法错误,差不多算解决啦
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式