javax.naming.NoInitialContextException:

Hi All

I created connection pool in weblogic . Now I am trying to access dbtables from database using datasource name. This time i am getting

javax.naming.NoInitialContextException:

This is my code snippet. plz help me.

import java.sql.*;

import javax.sql.*;

import javax.naming.*;

public class Testcon {

public static void main(String args[])

{

try{

System.out.println("try block entered");

Context ctx = new InitialContext();

System.out.println("context created");

DataSource ds = (DataSource)ctx.lookup("aaa/satish/jndiname");

System.out.println("jndi found");

Connection con = ds.getConnection();

System.out.println("connection created");

Statement stmt = con.createStatement();

ResultSet rs = stmt.executeQuery("select project_id from projectdetails");

if(rs.next())

{

System.out.println("Project_id\t"+rs.getString(1));

}

}

catch(Exception e){

System.out.println("Exception :\t"+e);

}

}

}

regards

satish

[1104 byte] By [bsatisha] at [2007-11-27 4:03:40]
# 1

Hi Satish,

Just check this link if it can help u out...

http://java.sun.com/products/jndi/tutorial/getStarted/faq/runtime.html

I was also getting same runtime error..but i was trying to lookup file using file system..

So i have to place the file system api's availble with JNDI in jre/lib/ext.

Good luck

hetal_giria at 2007-7-12 9:08:27 > top of Java-index,Core,Core APIs...