4

I'm just getting started using Roo and am excited about it's possibilities. However I am having problems trying to connect to my postgresql database. I have searched their forum and the internet without solving my problem. Here is my environment:

  • Eclipse 3.6.1
  • GWT 2.1.1
  • SpringSource Tool Suite 2.5.2.RELEASE
  • Spring Roo 1.1.1.RELEASE
  • PostgreSQL v.8.3.11 database

Steps I have taken: - Created a new Spring Roo project from the Spring Dashboard - Opened roo shell and executed:

persistence setup --provider HIBERNATE --database POSTGRES
  • Opened the database.properties file and added:

--username --password --url

  • back to roo shell and executed:

    database introspect --schema no-schema-required

This brought up the dialog showing the add-ons available for postgresql executed:

addon install id --searchResultId 01

roo returned:

Target resource(s):
-------------------
spring-roo-postgres-jdbc4-wrapper (9.0.0.801_jdbc4_0001)

Deploying...done.

Then when I auto complete the database introspect command I get:

database introspect --schema unable-to-obtain-connection

and when I execute it I get the JDBC driver not available for 'org.postgresql.Driver'

So, I am assuming my connection properties are not right, but am not sure. Our database uses SSL and I have had to add the following to my connection url to connect from my other projects:

jdbc:postgresql://10.104.0.41:5432/mydb?ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory

Here is the source from my database.properties file:

database.driverClassName=org.postgresql.Driver
database.url=jdbc\:postgresql\://10.104.0.41\:5432/mydb
database.username=xxx
database.password=...
ssl=true
sslfactory=org.postgresql.ssl.NonValidatingFactory

I have tried removing the \ 's in the file with no change and I have tried a variety of connection url combinations. I'm thinking the url is the problem, but am not sure at this point. Also something weird is yesterday when I tried to install the driver add-on using the roo1.1.1.RELEASE I got a timeout because of a key certification issue. I used the roo1.1.2.BUILD-SNAPSHOT and was able to get around that, but then I would get an NPE error trying to run the introspect command. I installed SpringSource Tool Suite fresh today, deleted my .m2 repository, and started a new project using roo1.1.1, was able to install the driver but now can't get connected. Any help would be much appreciated, I'm kinda stuck until I can reverse engineer some tables. I should also note that I can connect to the database through the data source explorer in eclipse with these connection properties and this connection url. I have also connected in other projects that were not using roo and hibernate. I can also connect to a local Derby database with roo.

Thanks so much, Mitch

2 Answers 2

1

For those who land on this page now. To solve the problem you have to execute:

addon install id --searchResultId 02

because 9.0.801.0001 Postgres is the correct version if your using newer Postgre.

0

I don't know anything about "roo", so, you may want to adapt my answer to make it work with roo.

and when I execute it I get the JDBC driver not available for 'org.postgresql.Driver'

It means that the JDBC driver JAR is not in your classpath. Go to this page, download the appropriate driver (JDBC 4, if you are in doubt), and add it to your classpath. If you are using maven, you may want to add this dependency (adapt the version tag):

<dependency>
    <groupId>postgresql</groupId>
    <artifactId>postgresql</artifactId>
    <version>...</version>
</dependency>
2
  • 2
    Thanks for the reply, I had tried that initially, but it turns out that roo doesn't work with the jdbc4 driver, after I switched to the jdbc3 version it made the connection.
    – mcfar
    Feb 4, 2011 at 16:45
  • A user requested more detail to my solution so here it is. To add the jdbc3 driver choose that option from the roo shell. When the >>database introspect --schema no-schema-required command is executed it should have the jdbc3 driver listed and you can use the addon install id <enter correct search id> and it will install the driver.
    – mcfar
    Mar 4, 2011 at 4:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.