1 Reply Latest reply: Dec 28, 2012 12:32 PM by Frédéric Desbiens-Oracle RSS

    getConnection in a  Java Desktop App(ADF)

    Edward D.G.
      Il try to do this in a JAVA DESKTOP APLICATION:

      InitialContext initialContext;
      initialContext = new InitialContext();
      DataSource ds;
      ds = (DataSource)initialContext.lookup("java:comp/env/jdbc/SalesDS"); //throw errrorr!!!!!!!!!!!!!!!!
      cnn = ds.getConnection();

      How can i do this in a Java Desktop application???

      My jdev version is
        • 1. Re: getConnection in a  Java Desktop App(ADF)
          Frédéric Desbiens-Oracle

          The error you get is normal. Typically, the context is provided by a JEE container, such as Oracle WebLogic Server or Oracle GlassFish Server. Your desktop application lacks such a container.

          It is possible to implement custom JNDI behavior in Java. The blog entry below provides a sample. I didn't validate the contents, however.


          JEE containers usually encrypt the connection credentials; make sure your custom implementation does likewise if you choose to go this route.

          Best Regards,