Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I show SQL with Play Framework?

I have a Play app that uses a database, and for debugging purposes I want to show the SQL that JPA uses. How can I do this?

like image 344
mranders Avatar asked Jan 12 '11 19:01

mranders


People also ask

How can I use Java and SQL together?

STEP 1: Allocate a Connection object, for connecting to the database server. STEP 2: Allocate a Statement object, under the Connection created earlier, for holding a SQL command. STEP 3: Write a SQL query and execute the query, via the Statement and Connection created. STEP 4: Process the query result.

How do I run a SQL query on a database?

Enter the SQL command you want to run in the command editor. Click Run (Ctrl+Enter) to execute the command. Tip: To execute a specific statement, select the statement you want to run and click Run.


1 Answers

In application.conf, you can turn showing SQL on uncommenting jpa.debugSQL=true. This will give you the prepared statement queries with question marks in them. Also, Play uses Hibernate, so you can also use Hibernate properties. These can be written in application.conf directly or in a separate hibernate.properties file residing in the conf folder of your Play application.

like image 129
mranders Avatar answered Oct 05 '22 20:10

mranders