Lookup from Standalone Client

My previous blog was about accessing a JDBC resource from an ejb. 

This blog talks about accessing the JDBC resource i created in the last blog, from a standalone client.

I use the same configuration from my previous blog : jdbc/cactus for my resource that needs to be accessed.

My sample will have the following code:

InitialContext ctx = new InitialContext();

javax.sql.DataSource ds = (javax.sql.DataSource) ctx.lookup("jdbc/cactus";)

Connection c = ds.getConnection();

insert(......);

c.close();

Compile the sample

 Run the sample

 Note the included jars in the classpath

  • appserv-rt.jar
  • javaee.jar
  • appserv-admin.jar
  • imqjmsra.jar
  • derbyclient.jar

Also, observe the system properties for the server host and naming service port.

Comments:

that does not explained everything i'm sorry but didn't work witouth the j2ee.jar and other configuration try to do it best next time.

Posted by Jose Luis Ayerdis Espinoza on March 21, 2009 at 05:59 AM IST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

shalini_m

Search

Categories
Archives
« August 2015
SunMonTueWedThuFriSat
      
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
     
Today