axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark A. Richman" <m...@markrichman.com>
Subject Using JNDI from Web Service
Date Wed, 26 Dec 2001 14:57:02 GMT
Hi all!!!
 
Is it possible to reference a JNDI object from a web service's
implementation class? For example, I have a class I wish to expose as a
web service. This class is currently accessing a HypersonicSQL
DataSource using the usual "Class.forName("org.hsqldb.jdbcDriver")" and
associated DriverManager.getConnection() contructs.
 
How can I define a JDBC DataSource using JNDI and gain access to it from
my web service implementation?
 
Presumably, I'd want to replace all the prior code with something like
this:
 
InitialContext ctx = new InitialContext();
DataSource ds =
(javax.sql.DataSource)ctx.lookup("java:comp/env/jdbc/MyDataSource");
Connection con = ds.getConnection();
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(sql);
 
 
Thanks,
Mark A. Richman
http://www.markrichman.com <http://www.markrichman.com/> 
 
 

Mime
View raw message