|
This is a multi-part message in MIME format. -- -- [ Picked text/plain from multipart/alternative ] Hi, I'm trying to configure Tomcat to use UDBDConnectionPoolDataSource as statement pooled connection factory and can't get JNDI to work. Before run it under Tomcat I want to make sure that JNDI portion of the code would work. The code is: import java.sql.*; import javax.naming.*; import java.util.*; import com.ibm.db2.jdbc.app.UDBDataSource; public class UDBDataSourceExample1 { public static void main(java.lang.String[] args) throws Exception { UDBDataSource ds = new UDBDataSource(); ds.setDescription("Basic DataSource"); System.out.println("dataSource created"); Context ctx = new InitialContext(); ctx.rebind("BaseDataSource", ds); } } Error message when trying to rebind: javax.naming.NoInitialContextException: 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 .... and if I'm running the same code with initial context set as: import java.sql.*; import javax.naming.*; import java.util.*; import com.ibm.db2.jdbc.app.UDBDataSource; public class UDBDataSourceExample1 { public static void main(java.lang.String[] args) throws Exception { UDBDataSource ds = new UDBDataSource(); ds.setDescription("Basic DataSource"); System.out.println("dataSource created"); Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.fscontext.RefFSContextFactory"); env.put(Context.PROVIDER_URL, "file:/jdbc/DataSources"); System.out.println("envelope created"); // Establish a JNDI context. Context ctx = new InitialContext(env); System.out.println("Context created"); ctx.rebind("BaseDataSource", ds); } } javax.naming.NameNotFoundException; remaining name '"/jdbc/DataSources"' java/lang/Throwable.<init>()V+4 (Throwable.java:78) java/lang/Exception.<init>()V+1 (Exception.java:29) javax/naming/NamingException.<init>()V+1 (NamingException.java:112) javax/naming/NameNotFoundException.<init>()V+1 (NameNotFoundException.java 44... We are running V5R1 with all latest PTF installed and I run second example with fscontext.jar included in class path -- Content-Description: Blank Bkgrd.gif [ Blank Bkgrd.gif of type image/gif deleted ]
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.