Java仅输出初始化值

时间:2013-12-09 17:48:57

标签: java mysql jsf netbeans xhtml

我的Java项目只给出了初始值,而不是我需要的等式值。我已经用几种不同的方式测试了这一点,我注意到的是我的输出只是从初始值0.00而不是后方程值中提取。

以下是初始值

public class LaptopOrders {

private int orderSize = 0;
private String subTotal = "0.00";
private String tax = "0.00";
private String total = "0.00";

这是等式发生的地方,

public void orderDetails()
{
    orderSize = 0;
    double s = 0;
    double t = 0;

    try
    {
        Class.forName("com.mysql.jdbc.Driver");
    }
    catch(Exception e)
    {
        e.printStackTrace();
    }

    //statement and connections
    Connection connection = null;
    Statement statement = null;
    ResultSet resultSet = null;

    try
    {
        final String DATABASE_URL = "jdbc:mysql://localhost/HPLaptopWeb";
        connection = DriverManager.getConnection(DATABASE_URL, "team", "secret");
        statement = connection.createStatement();

        //Query to get subTotal
        resultSet = statement.executeQuery("SELECT * FROM cart WHERE orderNum='" + orderNum + "'");

        DecimalFormat df = new DecimalFormat("#0.00");

         while(resultSet.next())
         {
            s = (s + resultSet.getDouble(13));
            orderSize++;
         }

         subTotal = df.format(s);
         t = (s * .0625);
         tax = df.format(t);
         total = df.format(s + t);
    }

    catch (SQLException e)
    {      
        e.printStackTrace();
    }
    finally  //close the statement and connection
    {

        try
        {
            statement.close();
            connection.close();
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }
}

这是我知道输出具有小写“l”的输出,并且类是大写的,但是如果它没有小写“l”则它没有提取任何信息。

             <f:facet name="footer">
                 <b><h:outputText value="Subtotal: $#{laptopOrders.subTotal}"/></b><br />
                 <b><h:outputText value="Tax: $#{laptopOrders.tax}"/></b><br />
                 <b><h:outputText value="Total: $#{laptopOrders.total}"/></b>             
             </f:facet>

0 个答案:

没有答案