Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

I am unable to create initialcontext obejct  RSS feed

ramakoteswararao siddabad
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using eclipse 3.1 version,java1.4.1 version.

i am unable create the initialcontext obejct . I have written the following code.
public static void main(String[] args) throws NamingException, SQLException {

Hashtable props = new Hashtable();
InitialContext ctx = new InitialContext();
DataSource d=(DataSource)ctx.lookup("DataSource");
Connection con=d.getConnection();
Statement s=con.createStatement();
ResultSet rs = s.executeQuery("select * from emp");
ResultSetMetaData m=rs.getMetaData();

i am getting following error:

javax.naming.CommunicationException: localhost:389 [Root exception is Connection refused: connect]
at com.sun.jndi.ldap.Connection.<init>(Unknown Source)
at com.sun.jndi.ldap.LdapClient.<init>(Unknown Source)
at com.sun.jndi.ldap.LdapClient.getInstance(Unknown Source)
at com.sun.jndi.ldap.LdapCtx.connect(Unknown Source)
at com.sun.jndi.ldap.LdapCtx.<init>(Unknown Source)
at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(Unknown Source)
at com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(Unknown Source)
at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(Unknown Source)
at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(Unknown Source)
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.init(Unknown Source)
at javax.naming.InitialContext.<init>(Unknown Source)
at JndiConnection.main(
Caused by: Connection refused: connect
at Method)
at Source)
at Source)
at Source)
at Source)
at Source)
at<init>(Unknown Source)
at<init>(Unknown Source)
at com.sun.jndi.ldap.Connection.createSocket(Unknown Source)
... 14 more

Could you please give me advice to go head in this issue.
Mark Spritzler
Posts: 17309
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have closed your duplicate thread below. Please refrain from posting duplicates.

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!