I am trying out anorm to execute a number of insert statements, and then return the value of LAST_INSERT_ID(). But I am getting an error saying my SQL syntax is invalid.
Can anyone tell me how to check and see what the final generated SQL that is sent ty MySQL looks like?
Anorm doesn't really generate SQL, you do. But there is a way to log the exact queries that are sent over the wire to the console (after the statements are prepared, assuming you're using Anorm within Play).
Assuming you're using a single database called default (the default configuration), add the following to your application.conf:
db.default.logStatements=true
Then you can save the following to conf/logger.xml:
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%-5level - %msg%n</pattern>
</encoder>
</appender>
<logger name="com.jolbox.bonecp" level="NONE">
<appender-ref ref="STDOUT" />
</logger>
<logger name="play" level="INFO">
<appender-ref ref="STDOUT" />
</logger>
<logger name="application" level="NONE">
<appender-ref ref="STDOUT" />
</logger>
</configuration>
The key line in the file is related to BoneCP logging, but we want to put in lines for the application and play loggers as well, so we don't mess up the default logging.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With