This discussion is archived
1 Reply Latest reply: Dec 28, 2012 10:32 AM by Blueberry Coder RSS

getConnection in a  Java Desktop App(ADF)

Edward D.G. Newbie
Currently Being Moderated
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)
    Blueberry Coder Journeyer
    Currently Being Moderated

    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,



  • Correct Answers - 10 points
  • Helpful Answers - 5 points