i m trying to execute multiply function in sql but it doesnt compute d values.
d problem is i forgt to create a total row to store the multiplied values n i cant create a new table or add d row..
here is d code i m using n d error it is displayin.
do help.
<%
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();
}
%>
total:
com.mysql.jdbc.StatementImpl@3b46c4
Instead of using two separate query use a single query to achieve this
For eg: