Track SQL output in Java

Asked

Viewed 85 times

2

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

Is there any way I can see the full script that was "played" on MySQL What went wrong? Like, he says he’s wrong about the clause WHERE. How can I see all that mounted to execute, since the INSERT?

  • you are using jsf?

  • Using the DAO standard? Queries are mounted manually or are using an automated way?

  • Using DAO and jsf standards yes.

1 answer

3

If you are setting up 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 properties tag of Hibernate.cfg.xml, or in JPA persistence.xml.

<property name="hibernate.show_sql" value="true" />

Browser other questions tagged

You are not signed in. Login or sign up in order to post.