• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Looking up DataSource

 
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I couldn't get the connection object to a Datasource configured in the App Server in stand alone client program.

But the following code works well in a EJB that is deployed in that server ..

Can any one tell me the reason for this .

Srini
[ October 16, 2004: Message edited by: srini vasan ]
 
Ranch Hand
Posts: 1087
Oracle Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the problem might be related in looking up initial context ...
are you able to get intialContext ?? try to print intialConext etc
[ October 23, 2004: Message edited by: Shailesh Chandra ]
 
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try (DataSource)ic.lookup("java:comp/env/jdbc/testDS");
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Shailesh Chandra:
the problem might be related in looking up initial context ...
are you able to get indiaContext ?? try to print intialConext etc


I'll try that
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Pradeep Bhat:
try (DataSource)ic.lookup("java:comp/env/jdbc/testDS");



Whats the difference b/w ic.lookup("java:comp/env/jdbc/testDS") and
ic.lookup("jdbc/testDS")

Can you explain me ?

Srini
 
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by srini vasan:


Whats the difference b/w ic.lookup("java:comp/env/jdbc/testDS") and
ic.lookup("jdbc/testDS")

Can you explain me ?

Srini



Both is not defference.

Because default of jndi is "java:comp/env" is default place to start lookup in Directory.
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by srini vasan:
I couldn't get the connection object to a Datasource configured in the App Server in stand alone client program.

But the following code works well in a EJB that is deployed in that server ..

Can any one tell me the reason for this .

Srini

[ October 16, 2004: Message edited by: srini vasan ]



Your error is NamingNotFoundException or NullPointerException ??

If NamingNotFoundException, you jndi or DD is wrong in configuration.
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm getting this exception :

NamingException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is the Source code of client


[ October 27, 2004: Message edited by: srini vasan ]
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Since you are using a standalone Java Client Application, it's probably running outside the JVM of your appserver. The url for lookup "java:comp/env/<beanJNDIName>", is the J2EE specification for looking EJB's (or other resources) INSIDE the same environment, not outside of the environment. You java client app has no idea about java:comp

Try giving entire url for lookup e.g.

context.lookup("<protocol>://<host>:<port>/<resourceName>")

On my box I have a DataSource registered in weblogic JNDI Namespace under context jdbc/Oracle_sid. From standalone java app I look up datasource as

DataSource ds = (DataSource)context.lookup("t3://localhost:7001/jdbc/Oracle_sid");

Connection connection = ds.getConnection();
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is it not the InitialContext got from getIntialContext Methood using the URL will tell where to look. Do we need to give full URL in the lookup?
 
nilesh Katakkar
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Murugham Patham
<quote>
Is it not the InitialContext got from getIntialContext Methood using the URL will tell where to look. Do we need to give full URL in the lookup?
</quote>

Yeah.. sorry.
Murugham you are right.You don't have to give full URL in the lookup.
 
reply
    Bookmark Topic Watch Topic
  • New Topic