Announcement Announcement Module
Collapse
No announcement yet.
DB2 database support in Roo Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • DB2 database support in Roo

    I wonder why Roo supports Oracle but IBM don't.

    We could use any other supported database (PostgreSQL, MySQL...) in development environment, but we need a lot of changes to manage table's owner in queries, for instance.

    Is there any plan to include DB2 in Roo?

    Thank you very much.

  • #2
    As you know Roo uses JPA for all persistence handling. The different JPA implementations (Hibernate, openJPA, EclipseLink) should support DB2 as well, so you should be able to simply configure it manually in your persistence.xml and your database.properties files.

    It would be great if you could open a feature enhancement ticket in our Jira to request support for DB2. Maybe you can even share your configurations in that ticket so we are sure that it all works fine.

    Cheers,
    Stefan

    Comment


    • #3
      Originally posted by Stefan Schmidt View Post
      As you know Roo uses JPA for all persistence handling. The different JPA implementations (Hibernate, openJPA, EclipseLink) should support DB2 as well, so you should be able to simply configure it manually in your persistence.xml and your database.properties files.

      It would be great if you could open a feature enhancement ticket in our Jira to request support for DB2. Maybe you can even share your configurations in that ticket so we are sure that it all works fine.

      Cheers,
      Stefan
      Thank you very much for your answer.

      Actually I'm evaluating to introduce Roo in our developments, so I can try whether it works with DB2.

      If we decide to use Roo and it has problems with DB2, we could create a ticket in your JIRA in order to assure that Roo works with all the possible databases.

      However, I haven't DB2 at home, so I couldn't collaborate if Roo is not approved.

      Kind regards.

      Comment


      • #4
        Roo just sets up normal JPA and therefore shouldn't have any DB2 issues given DB2 works with JPA implementations like Hibernate.

        All we really need to "add DB2 support" to Roo is the JDBC configuration details, such as the groupId/artifactId/version for the JDBC driver JAR, the JDBC connection string, and some sort of sensible username/password default (if needed; people using a non-memory DB are generally aware they'd need to set these manually when issuing the Roo command and/or afterwards in database.properties).

        As such if you could contribute the above information after a DB2 test via a Jira ticket it would be great for those who'd like to use DB2. There's no development required, just the simple configuration information above.

        Comment


        • #5
          Originally posted by Ben Alex View Post
          Roo just sets up normal JPA and therefore shouldn't have any DB2 issues given DB2 works with JPA implementations like Hibernate.

          All we really need to "add DB2 support" to Roo is the JDBC configuration details, such as the groupId/artifactId/version for the JDBC driver JAR, the JDBC connection string, and some sort of sensible username/password default (if needed; people using a non-memory DB are generally aware they'd need to set these manually when issuing the Roo command and/or afterwards in database.properties).

          As such if you could contribute the above information after a DB2 test via a Jira ticket it would be great for those who'd like to use DB2. There's no development required, just the simple configuration information above.
          I will try if Roo is selected as the tool for rapid developments (I would like, but at the end it doesn't depend on me)

          Thank you very much for your answer.

          Comment


          • #6
            I've added a new feature request in Jira:

            Add support for DB2 databases: https://jira.springsource.org/browse/ROO-603

            with a description how I've added DB2 support manually. I hope the description is sufficient so someone else can use it.

            Comment


            • #7
              Thanks for your detailed description! I will review it for possible inclusion in the next release.

              Cheers,
              Stefan

              Comment


              • #8
                DB2 driver not loaded

                Using sts 2.3 updated, db2 server 9.7.1, spring roo 1.0.2
                when setting DB2 as database while configuring persistence , maven cannot either download the db2jcc jar or load the jar in the local repository, after having installed it manually with the install-file maven command. (
                mvn install:install-file
                -Dfile=<path-to-file>
                -DgroupId=<group-id>
                -DartifactId=<artifact-id>
                -Dversion=<version>
                -Dpackaging=<packaging>
                )
                When executing mvn package the log says that it could not download the db2jcc library and it looks like the one located inside my local repo is not available to maven to properly configure jpa persistence.
                I tried both with db2jcc.jar and db2jcc4.jar setting their -Dversion parameter accordingly to 3.50.152 and 4.8.86, -DgroupId=com.ibm

                Can you give me any hint to have db2jcc working?
                Help is very appreciated.

                Comment


                • #9
                  Originally posted by eltardo View Post
                  installed it manually with the install-file maven command. (
                  mvn install:install-file
                  -Dfile=<path-to-file>
                  -DgroupId=<group-id>
                  -DartifactId=<artifact-id>
                  -Dversion=<version>
                  -Dpackaging=<packaging>
                  )
                  Can you please post the exact Maven command you used?

                  Comment


                  • #10
                    Hi and thank you 4 the response;
                    the command i used is:
                    mvn install:install-file -DgroupId=com.ibm -DartifactId=db2jcc -Dversion=3.50.152 -Dpackaging=jar -Dfile=/Users/tobia/Develop/Libs/db2/db2jcc.jar
                    Of course i have db2jcc.jar lib in the path indicated.

                    Thank you very much
                    eltardo

                    Comment


                    • #11
                      So your POM needs an entry like this (sorry if this is teaching you how to suck eggs, but you didn't post your POM):

                      Code:
                      <project ...
                          ...
                          <dependencies>
                              <dependency>
                                  <groupId>com.ibm</groupId>
                                  <artifactId>db2jcc</artifactId>
                                  <version>3.50.152</version>
                              </dependency>
                          </dependencies>
                          ...
                      </project>
                      The other thing you can check is whether the install-file goal actually saved the driver as <user_home>/.m2/repository/com/ibm/db2jcc/3.50.152/db2jcc-3.50.152.jar.

                      Comment


                      • #12
                        You are alright, I did not post my pom.xml but I checked that spring roo 1.0.2 put that entry inside pom.xml and already checked whether the file is correctly installed in the .m2 path and everything looked correct. I will post you some details:

                        .m2 repo:
                        ll /Users/tobia/.m2/repository/com/ibm/db2jcc/3.50.152/db2jcc-3.50.152.jar
                        -rw-r--r-- 1 tobia staff 3226598 26 Feb 12:19 /Users/tobia/.m2/repository/com/ibm/db2jcc/3.50.152/db2jcc-3.50.152.jar

                        pom.xml (extract) :
                        <dependency>
                        <groupId>com.ibm</groupId>
                        <artifactId>db2jcc</artifactId>
                        <version>3.50.152</version>
                        </dependency>
                        There is no repository section that indicates to search inside local repo..Is it needed?
                        When executing perform eclipse command in roo shell the BUILD is SUCCESSFUL, even though roo tries to download db2jcc from repo (i think it eventually finds it in the local repo and doesn't raise any error)

                        But when trying to deploy or launch the webapp in tomcat (mvn tomcat:run) maven still says it is impossible to dl the jar
                        [INFO] Preparing tomcat:run
                        Downloading: http: //repository.springsource.com/...c-3.50.152.pom
                        [INFO] Unable to find resource 'com.ibm:db2jcc: pom:3.50.152' in repository com.springsource.repository.bundles.release (http: //repository.springsource.com/...undles/release)
                        Downloading: http: //repository.springsource.com/...c-3.50.152.pom
                        [INFO] Unable to find resource 'com.ibm:db2jcc: pom:3.50.152' in repository com.springsource.repository.bundles.external (http: //repository.springsource.com/...ndles/external)
                        Downloading: http: //repository.springsource.com/...c-3.50.152.pom
                        [INFO] Unable to find resource 'com.ibm:db2jcc: pom:3.50.152' in repository com.springsource.repository.bundles.milestone (http: //repository.springsource.com/...dles/milestone)
                        Downloading: http: //repository.springsource.com/...c-3.50.152.pom
                        [INFO] Unable to find resource 'com.ibm:db2jcc: pom:3.50.152' in repository com.springsource.repository.bundles.snapshot (http: //repository.springsource.com/...ndles/snapshot)
                        Downloading: http://repo1.maven.org/maven2/com/ib...c-3.50.152.pom
                        [INFO] Unable to find resource 'com.ibm:db2jcc: pom:3.50.152' in repository central (http: //repo1.maven.org/maven2)

                        and also when launching site from browser an exception is raised saying that:
                        GRAVE: Servlet.service() for servlet default threw exception
                        org.springframework.dao.DataAccessResourceFailureE xception: Could not create JPA EntityManager
                        .....
                        Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.ibm.db2.jcc.DB2Driver

                        Hope i did provide enough details and I really thank you for your support.
                        I didn't sleep tonite to try to solve this issue and I tested it with any persistence provider to see if anything changed.But the db2jcc driver seems to not be available to the application even though I can see it in the referenced libraries of sts 2.3 and such class(DB2Driver) is present inside the jar.

                        Comment


                        • #13
                          No, you never need to tell Maven to look in the local repo. Quite the opposite in fact; Maven will always check the local repo (in your case /Users/tobia/.m2/repository) for a given artifact before trying to download it from any remote repositories (which includes both private repos on your LAN as well as repos on the internet). Snapshot artifacts are more complicated but not relevant to your situation.

                          If you look closely at those five "Unable to find resource" errors, you will see that they relate to the driver's POM, not the driver's JAR file (which is already in your local repo and doesn't need to be downloaded, as per my previous para). Maven always tries to find the POMs for your project's dependencies in order to identify and download any transitive dependencies (in this case, any JARs upon which the driver itself might depend). Because the driver probably wasn't built using Maven (shame on IBM!), there is no POM for it, so the download fails. As you see, Maven doesn't regard not finding a POM as fatal, so your build completes successfully anyway. But because there is no POM, you have to add the driver's own dependencies manually to your project's POM in the same way as if your project used those JARs itself. You can only find out these dependencies (if any) by reading the driver's documentation. I've never used DB2 so I can't tell you, however I've yet to come across a JDBC driver that does have dependencies (not counting the SQL Server 2000 driver, which rather inconveniently ships as three separate JAR files).

                          So it looks as though the driver is indeed present. You can check this by building your project using "mvn package", going into your project's "target" folder, and looking for the driver inside your WAR file's WEB-INF/lib folder.

                          As to why commons-dbcp can't load the driver, I'm not sure. How about you post your project's database.properties file? Remember to use the [ CODE ] tags though (without the spaces of course)!

                          The other thing you could do is inspect the source code for commons-dbcp to find out why it throws that "Cannot load JDBC driver class" exception.

                          Comment


                          • #14
                            ok, i see.
                            I will check the documentation for any dependency and then i'll try to configure my pom accordingly.
                            I will at last return here and give my feedback on the investigation and a solution if i'll find any.
                            I'd like to thank you for your precious help.
                            pls feel free to post any idea if any.
                            eltardo

                            Comment


                            • #15
                              It works!
                              Finally I got all the stuff working..
                              the problem was inside the database.properties file.
                              building the project from the roo toolkit, roo eventually insert a space " " char at the end of the driver property line:
                              <code>database.driverClassName=com.ibm.db2.jcc.DB2 Driver </code>

                              removing that space (after, of course, installing the driver manually into maven local repository) the application resolves correctly the driver dependency, and has the db2 correctly working.

                              thank you andrew for your interest and support, your advices were extremely important to identify the problem's nature.

                              Comment

                              Working...
                              X