简体   繁体   中英

MySQL or Tomcat log query

I am having trouble with a particular query, it runs perfectly well in SQLYog but not in my JSP page. I get no results in my JSP page and I also get no errors either, but again if I run the same query direct on the database I get the expected results.

I would like to be able to see what query is trying to be sent to the MySQL server, then hopefully I can figure what maybe going astray. Can this be done?

I am using MySQL Server 5.5 for Windows 64bit, Tomcat 7 for Windows 64bit and my connection class is as follows:

public static Connection getConnection()
{
    settings settings1 = new settings();
    Connection connection = null;
    try
    {
        Class.forName("com.mysql.jdbc.Driver").newInstance();
        connection = DriverManager.getConnection("jdbc:mysql://" + dbHost + "/" + settings1.db + "?useUnicode=true&characterEncoding=UTF-8", settings1.dbUsername, settings1.dbPassword);
    }
    catch(Exception exception)
    {
        exception.printStackTrace();
    }
    return connection;
}

Any help to enable logging would be much appreciated :-)

The query is as follows:

SELECT product.ID, product.partCodePS, product.partCodeManufacturer, product.pName, product.priceCost, product.priceSell, product.reorderLevel, product.location, brand.leadTime, SUM(order_product.unitPrice)
FROM product
INNER JOIN order_product ON (product.ID = order_product.productID)
INNER JOIN brand ON (product.brandID = brand.ID)
INNER JOIN order ON (order_product.orderID = order.ID)
WHERE (product.isWebsite =1 AND order.o_statusID IN (1,2,3,4,5,11,12,14,15))
GROUP BY order_product.unitPrice

您可以使用General Query Logging MySQL选项查看对MySQL服务器的所有查询。

Are you sure your query in jsp page is executed? can you put the code of your jsp page?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM