
已解决问题
谷歌xumu2012用户在2013.06.15提交了关于“云度π1jsp 页面怎么添加**到MYsql**库?”的提问,欢迎大家涌跃发表自己的观点。目前共有1个回答,最后更新于2024-12-25T12:19:20。添加书籍信息页面:body><h2align="center">书籍信息添加</h2>
<center>
<table>
<formaction="/kcsj/houtai/add.jsp">
<tr>
<td>书号:</td>
<td><inputtype="text"name="id"></td>
</tr>
<tr>
<td>书名:</td>
<td><inputtype="text"name="bookname"></td>
</tr>
<tr>
<td>作蘸</td>
<td><inputtype="text"name="autor"></td>
</tr>
<tr>
<td>出版社:</td>
<td><inputtype="text"name="press"></td>
</tr>
<tr>
<td>价格:</td>
<td><inputtype="text"name="price"></td>
</tr>
<tr>
<td>数量:</td>
<td><inputtype="text"name="**m"></td>
</tr>
<tr>
<td> <inputtype="submit"value="提交"></td>
<td> <inputtype="reset"value="重置"></td>
</tr>
</table>
</center>
</body>**库打印页面:publicStringgetString(Stringstr)
{
if(str==**ll)
{
str="";
}
else
{
try
{
byte[]b=str.getBytes("ISO-8859-1");
str=newString(b);
}
catch(Exceptione)
{
e.printStackTrace();
}
}
returnstr;
}
%>
<%
Stringid=request.getParameter("id");
Stringbookname=request.getParameter("bookname");
Stringautor=request.getParameter("autor");
Stringpress=request.getParameter("press");
Stringprice=request.getParameter("price");
String**m=request.getParameter("**m");
id=getString(id);
bookname=getString(bookname);
autor=getString(autor);
press=getString(press);
price=getString(price);
**m=getString(**m);
intidVaule=Integer.parseInt(id);
intpriceVaule=Integer.parseInt(price);
int**mVaule=Integer.parseInt(**m);
Connectioncon=**ll;
Statementstmt=**ll;
ResultSetrs=**ll;
try
{
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/student","root","123456");
stmt=con.createStatement(ResultSet.TYPE_SCROLL_IN**NSITIVE,ResultSet.CONCUR_READ_ONLY);
Stringsql="insertintotable2values("+"idVaule"+","+"'"+bookname+"'"+","+"'"+autor+"'"+","+"'"+press+"'"+","+"+priceVaule+"+","+"+**mVaule+"+",)";
inti=stmt.executeUpdate(sql);
if(i>0)
{
out.println("添加成功");
}
Stringsql1="select*fromtable2";
rs=stmt.executeQuery(sql1);
out.println("<tableborder='1'>");
out.println("<tr>");
out.println("<thwidth=80>"+"书号");
out.println("<thwidth=50>"+"书名");
out.println("<thwidth=100>"+"作者");
out.println("<thwidth=80>"+"出版社");
out.println("<thwidth=80>"+"价格");
out.println("<thwidth=100>"+"数量");
out.println("</tr>");
while(***.next())
{
intid1=rs.getInt(1);
Stringbookname1=rs.getString(2);
Stringautor1=rs.getString(3);
Stringpress1=rs.getString(4);
Stringprice1=rs.getString(5);
int**m1=rs.getInt(6);
out.println("<tr>");
out.println("<td>"+id+"</td>");
out.println("<td>"+bookname1+"</td>");
out.println("<td>"+autor1+"</td>");
out.println("<td>"+press1+"</td>");
out.println("<td>"+price1+"</td>");
out.println("<td>"+**m1+"</td>");
out.println("</tr>");
}
out.println("</table>");
rs.close();
stmt.close();
con.close();
}
catch(Exceptione)
{
System.out.println("e="+e.toString());
}出现错误提示:Youh**eanerrorinyourSQLsyntax;checkthema**althatcorrespondstoyourMySQLserverversionfortherightsyntaxtousenear'+**m+,)'atline1谢谢了啊我没分!!好心人帮帮忙啦希望大家能够帮助她。
详细问题描述及疑问:添加书籍信息页面:body>
<h2align="center">书籍信息添加</h2>
<center>
<table>
<formaction="/kcsj/houtai/add.jsp">
<tr>
<td>书号:</td>
<td><inputtype="text"name="id"></td>
</tr>
<tr>
<td>书名:</td>
<td><inputtype="text"name="bookname"></td>
</tr>
<tr>
<td>作蘸</td>
<td><inputtype="text"name="autor"></td>
</tr>
<tr>
<td>出版社:</td>
<td><inputtype="text"name="press"></td>
</tr>
<tr>
<td>价格:</td>
<td><inputtype="text"name="price"></td>
</tr>
<tr>
<td>数量:</td>
<td><inputtype="text"name="**m"></td>
</tr>
<tr>
<td> <inputtype="submit"value="提交"></td>
<td> <inputtype="reset"value="重置"></td>
</tr>
</table>
</center>
</body>**库打印页面:publicStringgetString(Stringstr)
{
if(str==**ll)
{
str="";
}
else
{
try
{
byte[]b=str.getBytes("ISO-8859-1");
str=newString(b);
}
catch(Exceptione)
{
e.printStackTrace();
}
}
returnstr;
}
%>
<%
Stringid=request.getParameter("id");
Stringbookname=request.getParameter("bookname");
Stringautor=request.getParameter("autor");
Stringpress=request.getParameter("press");
Stringprice=request.getParameter("price");
String**m=request.getParameter("**m");
id=getString(id);
bookname=getString(bookname);
autor=getString(autor);
press=getString(press);
price=getString(price);
**m=getString(**m);
intidVaule=Integer.parseInt(id);
intpriceVaule=Integer.parseInt(price);
int**mVaule=Integer.parseInt(**m);
Connectioncon=**ll;
Statementstmt=**ll;
ResultSetrs=**ll;
try
{
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/student","root","123456");
stmt=con.createStatement(ResultSet.TYPE_SCROLL_IN**NSITIVE,ResultSet.CONCUR_READ_ONLY);
Stringsql="insertintotable2values("+"idVaule"+","+"'"+bookname+"'"+","+"'"+autor+"'"+","+"'"+press+"'"+","+"+priceVaule+"+","+"+**mVaule+"+",)";
inti=stmt.executeUpdate(sql);
if(i>0)
{
out.println("添加成功");
}
Stringsql1="select*fromtable2";
rs=stmt.executeQuery(sql1);
out.println("<tableborder='1'>");
out.println("<tr>");
out.println("<thwidth=80>"+"书号");
out.println("<thwidth=50>"+"书名");
out.println("<thwidth=100>"+"作者");
out.println("<thwidth=80>"+"出版社");
out.println("<thwidth=80>"+"价格");
out.println("<thwidth=100>"+"数量");
out.println("</tr>");
while(***.next())
{
intid1=rs.getInt(1);
Stringbookname1=rs.getString(2);
Stringautor1=rs.getString(3);
Stringpress1=rs.getString(4);
Stringprice1=rs.getString(5);
int**m1=rs.getInt(6);
out.println("<tr>");
out.println("<td>"+id+"</td>");
out.println("<td>"+bookname1+"</td>");
out.println("<td>"+autor1+"</td>");
out.println("<td>"+press1+"</td>");
out.println("<td>"+price1+"</td>");
out.println("<td>"+**m1+"</td>");
out.println("</tr>");
}
out.println("</table>");
rs.close();
stmt.close();
con.close();
}
catch(Exceptione)
{
System.out.println("e="+e.toString());
}出现错误提示:Youh**eanerrorinyourSQLsyntax;checkthema**althatcorrespondstoyourMySQLserverversionfortherightsyntaxtousenear'+**m+,)'atline1谢谢了啊我没分!!好心人帮帮忙啦期待您的答案,谢了,下次有事儿别忘了找我
!