on 07-06-2006 3:02 PM
My application is running on SAP WAS. I want to connect to a data source on different WAS. The below code throws NameNotFoundException. But if i connect through the data source on the same machine the code works fine.
InitialContext ctx = null;
Properties ctxProp = new Properties();
ctxProp.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sap.engine.services.jndi.InitialContextFactoryImpl");
ctxProp.put(Context.PROVIDER_URL, "machine-name:50004");
ctxProp.put(Context.SECURITY_PRINCIPAL, "Administrator");
ctxProp.put(Context.SECURITY_CREDENTIALS, "*********");
try
{
ctx = new InitialContext(ctxProp); DataSource ds = (DataSource) ctx.lookup("jdbc/SAPWASDB");
Connection con = ds.getConnection();
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("select * from BC_COMPVERS");
while (rs.next())
{ System.out.println("**********Values" + example);
}
}
catch (NamingException e)
{
System.err.println("**********Error" + e);
}
catch(SQLException e)
{
System.err.println("**********Error SQL" + e);
}
Hi venkatesh,
Did you added other machine entries into your host file. Are you able to deploy on other m/c WAS?. If your able to deploy on other machine ideally it should work.
which line its giving "NameNotFoundException"...Is that table exist?
Regards
suresh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.