Measuring sql runtime in a Java application

Is there an easy way to measure the execution time of all sql statements that are executed by JDBC and print the result in the output?

Some may advise me to use AOP for this, but I try to avoid this if possible. Is there another way?

+5
source share
5 answers

If you are not using an application on the application server that provides you with a data source, you can find the log4jdbc project , which will be useful, the logger jdbc.sqltimingprovided by the project will allow you to record the execution of the executed SQL queries.

, DataSources, , DataSource ConnectionSpy. .

, , :

  • P6Spy, . , ( ), .
  • API JAMon SQL. JAMon API .
+2

.

  • Sql Server //io/etc. , , .

  • AviCode .

  • sql , sql.

, . , , , .

- ?

+1

. Sql Recorder JDBC. .

- , P6Spy?

+1

, java-, , , .

System.out.println( ()); stmt.executeUpdate(); System.out.println( ());

, SQL, SQL Query, , .

+1

All Articles