我试图在 sql 中执行乘法函数,但它不计算 d 值。d 问题是我忘记创建一个总行来存储相乘的值 ni 不能创建一个新表或添加 d 行..这是 d 代码我使用它显示的 nd 错误。帮忙。
<%
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection conexion = DriverManager.getConnection("jdbc:mysql://localhost:3306/invent", "root", "hpdj850c");
if (!conexion.isClosed())
{
Statement st = conexion.createStatement();
ResultSet rs = st.executeQuery("select * from store");
Statement sta = conexion.createStatement();
ResultSet r = sta.executeQuery("select (rate*quantity) from store");
out.println("<table class=\"twelve\"><thead><tr><th>Id</th><th>Name</th><th>Category</th><th>Rate</th><th>Quantity</th><th>Total</th></tr></thead>");
while (rs.next() & r.next())
{
out.println("<tr>");
out.println("<td>"+rs.getObject("itemno")+"</td>");
out.println("<td>"+rs.getObject("name")+"</td>");
out.println("<td>"+rs.getObject("category")+"</td>");
out.println("<td>"+rs.getObject("rate")+"</td>");
out.println("<td>"+rs.getObject("quantity")+"</td>");
out.println("<td>"+r.getStatement() + "</td>");
out.println("</tr>");
}
out.println("</table>");
conexion.close();
}
else
out.println("fail");
}
catch (Exception e)
{
out.println("Exception " + e);
e.printStackTrace();
}
%>
全部的:
com.mysql.jdbc.StatementImpl@3b46c4