On Jun 5, 2013, at 4:10 AM, Lutischán Ferenc <lutisch...@gmail.com> wrote:

> Dear Daniel,
> 
> Thanks for your reply.
> My Tomcat version is 7.0.35. It is under CentOS 5.8.
> 
> My datasource config is:
> <Resource name="jdbc/xxx" auth="Container" 
> driverClassName="org.postgresql.Driver" 
> factory="org.apache.tomcat.jdbc.pool.DataSourceFactory" initialSize="1" 
> maxIdle="20" maxActive="20" maxWait="5000" password="xxx" 
> type="javax.sql.DataSource" url="jdbc:postgresql://10.3.76.41/xxx" 
> username="xxx" validationQuery="select 1" 
> jdbcInterceptors="ConnectionState;SlowQueryReportJmx(threshold=1000)" 
> testOnBorrow="true"/>
> 
> There is my java code:
>        Map<String, SlowQueryReportJmx.QueryStats> map = 
> SlowQueryReportJmx.getPoolStats("java:comp/env/jdbc/" + poolName);

And where are you trying to run this?

> I tried the config with 
> jdbcInterceptors="ConnectionState;SlowQueryReport(threshold=1000)",
> but there is no messages in the Tomcat log files.

With both SlowQueryReport and SlowQueryReportJmx, you should see entries in 
your log files when a slow query occurs.  In the case of your configuration, a 
slow query would be one that lasts longer than one second.  

If you have a query that runs for longer than one second, you'll see a log 
entry at the WARN level and it'll start with "Slow Query Report SQL=".

If you don't see these…

  1.) Make sure that your application is taking a connection from the 
connection pool and using that to execute the query.
  2.) Make sure that your query is actually running for longer than one second 
or for testing purposes lower the threshold so that your query runs longer than 
the threshold.
  3.) Make sure that your logging configuration is not preventing the entry 
from being displayed.  The default logging.properties file that is included 
with Tomcat should show these messages.

Dan

> 
> Thanks,
>      Ferenc
> 
> 2013.06.04. 16:20 keltezéssel, Daniel Mikusa írta:
>> On Jun 4, 2013, at 6:26 AM, Lutischán Ferenc <lutisch...@gmail.com> wrote:
>> 
>>> Dear Users,
>>> 
>>> Please help to me:
>>> How to get SlowQueryReport statistics?
>> Usually these are logged as WARN messages.  Unless you use 
>> SlowQueryReportJmx and then they are logged and sent as JMX notifications.
>> 
>>> I tried:
>>> 
>>> Map<String,SlowQueryReport.QueryStats> map = 
>>> SlowQueryReport.getPoolStats("java:comp/env/jdbc/xxx");
>>> and
>>> Map<String,SlowQueryReport.QueryStats> map = 
>>> SlowQueryReport.getPoolStats("xxx");
>>> 
>>> The result in both case was a null map.
>> Can you elaborate on what you are trying to do here?
>> 
>> Are you using Tomcat?
>> 
>> If so…
>>   1.) What version are you using?
>>   2.) How do you have your data source configured?  Please include the 
>> resource tag.
>> 
>> If not…
>>   1.) Are you using the Tomcat's jdbc-pool directly?
>>   2.) How are you setting it up?
>>   3.) How is it configured?
>>   4.) What version are you using?
>> 
>> Dan
>> 
>>> 
>>> Thanks,
>>>       Ferenc
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
>>> For additional commands, e-mail: users-h...@tomcat.apache.org
>>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
>> For additional commands, e-mail: users-h...@tomcat.apache.org
>> 
>> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to