java - MySQL或Tomcat日志查询

标签 java mysql tomcat logging

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

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

我在 Windows 64 位上使用 MySQL Server 5.5,在 Windows 64 位上使用 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

最佳答案

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

关于java - MySQL或Tomcat日志查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19926954/

相关文章:

php - 获取重复条目错误消息并在 if 语句中使用

java - java jpa生成值异常

gwt - war 文件中的 Maven Artifact 版本号

tomcat - ELB后面的tomcat如何重定向到https

java - 使用方法在 Jpanel 内添加 JButton 时,如何保持最后添加的按钮在 View 中?

java - Java 获取 JSON 数组的方法

Python pyodbc 奇怪的 unicode 字节码

tomcat - openrdf-sesame database/triplestore 在 eclipse wtp 项目中与 tomcat

java - 如何使用 iText Java 将数据附加到现有 pdf 文件

java - 搜索从 xml 文档创建的 DOM 并将值复制到电子表格/csv