Uploaded image for project: 'Derby'
  1. Derby
  2. DERBY-4907

EmbeddedXADataSource with ;create=true attribute set in setDatabaseName fails with java.sql.SQLException: Database not available

    Details

    • Urgency:
      Low
    • Issue & fix info:
      Newcomer, Repro attached, Workaround attached

      Description

      Setting the ;create=true attribute in setDatabaseName with EmbededXADataSource and EmbeddedXADataSource40 fails with
      $ java TestDerbyCreate
      Exception in thread "main" java.sql.SQLException: Database not available
      at org.apache.derby.jdbc.EmbeddedXADataSource.setupResourceAdapter(Embe
      dedXADataSource.java:175)
      at org.apache.derby.jdbc.EmbeddedXADataSource.getXAConnection(EmbeddedX
      DataSource.java:101)
      at TestDerbyCreate.main(TestDerbyCreate.java:18)

      using the create attributie in databaseName works fine with EmbeddedDataSource.

      Using setCreateDatabase("create") with EmbeddedXADataSource is a good work around and I think generally preferable.

      import java.sql.*;
      import javax.sql.*;

      public class TestDerbyCreate
      {
      public static void main(String[] args) throws Throwable
      {
      org.apache.derby.jdbc.EmbeddedXADataSource ds =
      new
      org.apache.derby.jdbc.EmbeddedXADataSource();

      ds.setDatabaseName("TestDB;create=true");
      ds.setUser("dbuser1");
      ds.setPassword("dbpwd1");

      PooledConnection pooledConn = ds.getXAConnection();
      Connection conn = pooledConn.getConnection();

      System.out.println("Database product: " +
      conn.getMetaData().getDatabaseProductName());
      System.out.println("Database version: " +
      conn.getMetaData().getDatabaseProductVersion());
      System.out.println("Driver name: " +
      conn.getMetaData().getDriverName());
      System.out.println("Driver version: " +
      conn.getMetaData().getDriverVersion());
      System.out.println("JDBC driver major ve

        Attachments

        1. derby4907_final.diff
          5 kB
          Siddharth Srivastava
        2. derby4907_with_contains_fix.diff
          6 kB
          Dave Brosius
        3. derby4907.diff
          6 kB
          Siddharth Srivastava
        4. derby4907.diff
          5 kB
          Siddharth Srivastava
        5. derby4907.diff
          7 kB
          Siddharth Srivastava
        6. derby4907.diff
          7 kB
          Siddharth Srivastava
        7. derby4907.txt
          2 kB
          Siddharth Srivastava

          Issue Links

            Activity

              People

              • Assignee:
                siddharthsrivastava Siddharth Srivastava
                Reporter:
                kmarsden Kathey Marsden
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: