Uploaded image for project: 'Thorntail'
  1. Thorntail
  2. THORN-570

Creating datasources using the DatasourcesFraction should be straight forward

    XMLWordPrintable

Details

    • Enhancement
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Done
    • 1.0.0.Final
    • 2016.12.1
    • core
    • None

    Description

      At current creating a datasource programatically is quite involved and requires hoop jumping

      We have to create a module for our driver:

      <?xml version="1.0" ?>
      <module xmlns="urn:jboss:module:1.3" name="org.postgresql">
          <resources>
              <artifact name="org.postgresql:postgresql:${version.postgresql}"/>
          </resources>
          <dependencies>
              <module name="javax.api"/>
              <module name="javax.transaction.api"/>
          </dependencies>
      </module>
      

      Then we need to define a driver and the datasource using our DatasourcesFraction:

      new DatasourcesFraction()
      .jdbcDriver("org.postgresql", (d) -> {
          d.driverClassName("org.postgresql.Driver");
          d.xaDatasourceClass("org.postgresql.xa.PGXADataSource");
          d.driverModuleName("org.postgresql");
      })
      .dataSource("MyDS", (ds) -> {
          ds.driverName("org.postgresql");
          ds.connectionUrl("jdbc:postgresql://localhost:5432/mydb");
          ds.userName("postgres");
          ds.password("password");
      });
      

      The 80% use case for adding drivers should be as straight forward as:

      Include the driver dependency in your pom.xml and then:

      new DatasourcesFraction()
      .dataSource("MyDS", (ds) -> {
          ds.driverName("org.postgresql");
          ds.connectionUrl("jdbc:postgresql://localhost:5432/mydb");
          ds.userName("postgres");
          ds.password("password");
      });
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              justinwyer_jira Justin Wyer (Inactive)
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: