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);
%>
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);
%>
追问
我之前查到是语法错误,差不多算解决啦
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |