4 Replies Latest reply on Jul 13, 2004 10:55 AM by Armenio Pinto

    Dynamically create DataSources

    Armenio Pinto Newbie

      Hi there,

      Is is possible to dynamically (for example, inside a bean) to create a new DataSource in JBoss 3.2.3? Thanks in advance,

      Armenio Pinto

        • 1. Re: Dynamically create DataSources
          Darran Lofthouse Master

          Have you searched the forums? Approaches for this have been discussed in the past.

          • 2. Re: Dynamically create DataSources
            Armenio Pinto Newbie

            darranl, thanks for your reply. I searched the foruns and found some info, but unfortunatly, everyone seems to conclude that (currently) this is impossible to do.

            The question came up because I was having some problems connecting DIRECTLY to a database inside my bean, that is, with a new Connection(), instead of using DataSources. Is there any issue with this approach? After some time, Oracle started throwing "cannot alocate shared memory" errors, and a database restart was needed to solve the problem.

            So, I tryed the DataSource approach, and the problem was solved. But this is impossible, because the database access information is delivered in runtime, so a runtime and programtically DataSource creation was necessary.

            If anyone can help me it would be really great, because the production environment is currently in hold because of this issue.

            Thanks in advance,
            Armenio Pinto

            • 3. Re: Dynamically create DataSources
              Kabir Khan Master

              If it is impossible, as a workaround could you generate the *-ds.xml file and copy it to your deploy directory?

              • 4. Re: Dynamically create DataSources
                Armenio Pinto Newbie

                Humm... Yes, that could work, but it's kind of a "medieval" approach, isn't it :)? Also, I think there are some timing issues involved, as the descriptor is auto-deployed. Do you know any drawback about using "raw" connections, that is, created directly with a new Connection()?

                Thank you a lot,
                Armenio Pinto