与 Websphere v7.0 建立数据库连接时运行独立 Java 客户端所需的所有 Jars
代码
Hashtable parms = new Hashtable();
parms.put(Context.INITIAL_CONTEXT_FACTORY, Database.DB_CONTEXT_FACTORY);
parms.put(Context.PROVIDER_URL, Database.DB_PROVIDER_URL);
logger.debug("Using context of database with parameter "+parms);
context = new InitialContext(parms);
dataSource = (DataSource) context.lookup(getName());
logger.debug("Using context of database with and the context is "+dataSource);
Connection conn = dataSource.getConnection();
错误
ERROR com.ibm.nzna.shared.util.LogSystem - javax.naming.NoInitialContextException: Cannot instantiate class: com.ibm.websphere.naming.WsnInitialContextFactory [Root exception is java.lang.ClassNotFoundException: com.ibm.websphere.naming.WsnInitialContextFactory]
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:685)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:318)
at javax.naming.InitialContext.init(InitialContext.java:253)
at javax.naming.InitialContext.<init>(InitialContext.java:227)
at com.ibm.nzna.shared.db.Database.connect(Database.java:140)
at com.ibm.nzna.shared.db.DatabaseSystem.createConnection(DatabaseSystem.java:243)
at com.ibm.nzna.projects.qit.app.PCDInitializeThread.run(PCDInitializeThread.java:180)
at java.lang.Thread.run(Thread.java:780)
Caused by: java.lang.ClassNotFoundException: com.ibm.websphere.naming.WsnInitialContextFactory
at java.lang.Class.forName(Class.java:176)
at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:75)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:682)
... 7 more