Search code examples
intellij-ideajdbchsqldbintellij-14

View hsqldb content of petclinic application from intellij 14


i have cloned petclinic project and imported it in intellij 14.

My question is, when i am using the application on localhost how can i see the content of the hsqldb database which is used by default in the petclinic application ? My first attempt was to :

  • go in the database view from intellij

  • create an in memory new database with url equal to : jdbc:hsqldb:mem:petclinic

When i test the connection it is ok, even if the application server is not started, which is weard i think

When i start the application ./mvnw tomcat7:run in the database view i only get schemas : PUBLIC.PUBLIC with no table at all.

My question is so how to configure the database connection within intellj to see the content of the hsqldb used in the petclinic application ?

Thanks you.

To add clarification : If you have a look at the petclinic code [link] https://github.com/spring-projects/spring-petclinic you will see that hsqldb is already configured and launched at the start of the application. And that the configuration is

jdbc.driverClassName=org.hsqldb.jdbcDriver          
jdbc.url=jdbc:hsqldb:mem:petclinic
jdbc.username=sa
jdbc.password=

I guess i would need to reuse the same hsqldb than the one started by petclinic code, but i don't know how to achieve this from intellij once the application is started locally. Appreciate your help.


Solution

  • Well to answer my own question, this is what to do :

    Instantiate a spring bean just after the creation of the datasource bean and then launch the swing tool hsql database manager adding those simple lines of code :

    <bean depends-on="dataSource" class="org.springframework.beans.factory.config.MethodInvokingBean">
        <property name="targetClass" value="org.hsqldb.util.DatabaseManagerSwing" />
        <property name="targetMethod" value="main" />
        <property name="arguments">
            <list>
                <value>--url</value>
                <value>jdbc:hsqldb:mem:petclinic</value>
                <value>--user</value>
                <value>sa</value>
                <value>--password</value>
                <value></value>
            </list>
        </property>
    </bean>
    

    Then select the PUBLIC schema you will see all the tables :=)