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 11.1.2.3.0
  • 1. Re: getConnection in a  Java Desktop App(ADF)
    Blueberry Coder Journeyer
    Currently Being Moderated
    Hi.

    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.

    http://www.javacodegeeks.com/2012/04/jndi-and-jpa-without-j2ee-container.html

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

    Best Regards,

    Frédéric.

Legend

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