Hi,
I am new to WebSphere. I have copied a
java source from the IBM web site so that I can access the naming system and get a database connection using the WebSphere Application Server 4.0, but when I compile the .java, I got two errors from the compiler.
1. Variable "Context/INITAIL_CONTEXT_FACTORY" is not defined in the current context.
2. Cannot find type "javax/naming/Context"
----------------------------------Start
The following is the code fragment:
private final
String DATASOURCE = "ABC";
public Connection getConnection()
{
Connection conn = null;
try
{
java.util.Properties parms = new java.util.Properties();
parms.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
// access naming system
javax.naming.Context context = new javax.naming.InitialContext(parms);
// get DataSource factory object from naming system
Ds = (javax.sql.DataSource)context.lookup(DATASOURCE);
conn = ds.getConnection();
return conn;
}
catch (Exception t)
{
// DataSource not found. Throw Exception
}
-------------------------------End
I guess it has something to do with the Classpath setting, I did include most of the jar files in the classpath. However, I have no idea as to what jar files are needed here for the "Context".
Could anyone tell me what should I do to solve this compilation error. Thanks.