Follow the SQL output in Java

2

My application in java for web gives the error of SQL Syntax several times, but only indicates a trick of the SQL script that gives error.

Is there any way I can see the full script that was "played" in MySQL that gave error? Like, he says he has an error in the WHERE clause. How can I see everything that the has been set up to run, since INSERT ?

    
asked by anonymous 15.07.2014 / 01:17

1 answer

3

If you are assembling the queries manually, you can print the contents of your preparedStatement.

System.out.println(preparedStatement);

If you are using Hibernate, you can enable show_sql in the hibernate.cfg.xml properties tag, or in JPA's persistence.xml.

<property name="hibernate.show_sql" value="true" />
    
16.07.2014 / 05:10