Showing SQL statements with Keycloak

December 31, 2021 

Sometimes you might find yourself wondering whether there is some paranormal activity going on with your keycloak and its database. To check if things are still in the realm of physical reality, and to restore your child's faith in the programmer who never makes mistakes, it might be soothing to check what's actually happening to the database. To do this, create a new property named showSql and give it a value of true in your connectionsJpa spi. This is located in standalone.xml, standalone-ha.xml, or in domain.xml (if you've already graduated from kindergarten).

<spi name="connectionsJpa">
<provider name="default" enabled="true">
<properties>                        
<property name="dataSource" value="java:jboss/datasources/KeycloakDS"/>                        <property name="initializeEmpty" value="true"/>                        
<property name="migrationStrategy" value="update"/>                        
<property name="migrationExport" value="${jboss.home.dir}/keycloak-database-update.sql"/>
<property name="showSql" value="true"/>                    
</properties>                
</provider>            
</spi>

Then stare at the content of your server.log as long as your eyeballs can take it.

Samuli Seppänen
Petri Lammi
Author archive
menucross-circle