Announcement Announcement Module
No announcement yet.
[OT] Using H2 DB Console to view db for spring social samples? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • [OT] Using H2 DB Console to view db for spring social samples?

    Sorry for this off topic post. In our production app will be using something other than H2, but since the spring social samples all use an internal H2 db instance, I'd like to know how I could access the UserConnection table created for the JdbcUserConnectionRepository stuff. I have my db name set in MainConfig just like in spring social showcase.

    I can access the h2 console through /appname/admin/h2 and I'll enter in the jdbc url like:


    (added IFEXISTS=TRUE just to be sure it's created.)

    I can connect fine but I cannot seem to find the UserConnection table anywhere?

    Sorry again, I know OT so feel free to ignore if it's not just a quick 1 second answer.

  • #2
    It's not entirely are trying to see the UserConnection table, after all. In the H2 console, the JDBC URL is: jdbc:h2:mem:spring-social-showcase (user: sa, no password). You should see the UserConnection table from there.

    That said, you aren't required to use H2--and, in fact, I don't recommend using the currently-configured in-memory DB in production. You can create the UserConnection table in whatever database you have already (you can find the schema definition in the docs or in the spring-social-core JAR). Just be sure that the appropriate datasource is injected into JdbcUsersConnectionRepository.


    • #3
      Is this still the connection String for the spring social showcase? I am using the XML version which is configured like this:
      <jdbc:embedded-database id="dataSource" type="H2">
      <jdbc:script location="classpath:/org/springframework/social/connect/jdbc/JdbcUsersConnectionRepository.sql" />
      <jdbc:script location="classpath:/org/springframework/social/showcase/account/Account.sql" />
      <jdbc:script location="classpath:/org/springframework/social/showcase/account/data.sql" />

      In the console I can connect to jdbc:h2:mem:spring-social-showcase (user: sa, no password). but I don't see the table. I only see an INFORMATION_SCHEMA folder which contains tables but they look to be base h2 tables.


      • #4
        Well, that was the connection string I used the last time I was in Spring Social Showcase, but it looks like you're using the XML based example. For that, I had to connect to "jdbc:h2:mem:dataSource". I should probably fix that inconsistency.


        • #5
          thanks for the prompt response - I was able to connect using that string.