0

我在处理特定查询时遇到问题,它在 SQLYog 中运行得非常好,但在我的 JSP 页面中却没有。我在我的 JSP 页面中没有得到任何结果,我也没有得到任何错误,但是如果我直接在数据库上运行相同的查询,我会得到预期的结果。

我希望能够看到正在尝试将什么查询发送到 MySQL 服务器,然后希望我能弄清楚什么可能会误入歧途。这可以做到吗?

我在 Windows 64bit 上使用 MySQL Server 5.5,在 Windows 64bit 上使用 Tomcat 7,我的连接类如下:

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;
}

任何启用日志记录的帮助将不胜感激:-)

查询如下:

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
4

2 回答 2

0

你确定你在jsp页面中的查询被执行了吗?你能把你的jsp页面的代码吗?

于 2013-11-12T11:03:48.493 回答
0

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

于 2013-11-12T10:47:01.330 回答