Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id A1E0D9F9F7B for ; Fri, 22 Dec 2006 13:47:35 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-new, port 10024) with ESMTP id 19946-09 for ; Fri, 22 Dec 2006 13:47:30 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from vms042pub.verizon.net (vms042pub.verizon.net [206.46.252.42]) by postgresql.org (Postfix) with ESMTP id E5DE49F9DAD for ; Fri, 22 Dec 2006 13:47:29 -0400 (AST) Received: from [127.0.0.1] ([72.66.96.197]) by vms042.mailsrvcs.net (Sun Java System Messaging Server 6.2-6.01 (built Apr 3 2006)) with ESMTPA id <0JAO004L4S2VOR08@vms042.mailsrvcs.net> for pgsql-jdbc@postgresql.org; Fri, 22 Dec 2006 11:47:20 -0600 (CST) Date: Fri, 22 Dec 2006 12:47:20 -0500 From: Guy Rouillier Subject: Re: Connection pooling in java In-reply-to: To: pgsql-jdbc@postgresql.org Message-id: <458C1A28.4050905@burntmail.com> MIME-version: 1.0 Content-type: text/plain; charset=ISO-8859-1; format=flowed Content-transfer-encoding: 7bit X-Antivirus: avast! (VPS 0662-0, 12/22/2006), Outbound message X-Antivirus-Status: Clean References: User-Agent: Thunderbird 1.5.0.9 (Windows/20061207) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200612/117 X-Sequence-Number: 16349 janaka priyadarshana wrote: > hi all.. > > i am tring to use connection pool with postgresql..but it give an > Exception when it is going to execute the line following. > InitialContext().rebind("DataSource", source) > > > the cord is as follow. > > > > Jdbc3PoolingDataSource source = new Jdbc3PoolingDataSource(); > source.setDataSourceName("A Data Source"); > source.setServerName("localhost"); > source.setDatabaseName("mmsc"); > source.setUser("janaka"); > source.setPassword("1234"); > source.setMaxConnections(10); > try { > new InitialContext().rebind("DataSource", source); > } > catch (NamingException ex) { > System.out.println(ex.getMessage()); > ex.printStackTrace(); > } > > > > > the given exception is as follow.... > > > javax.naming.NoInitialContextException : Need to specify class name in > environment or system property, or as an applet parameter, or in an > application resource file: java.naming.factory.initial It's telling you what the problem is right there: you haven't supplied sufficient information to construct an initial context. Specifically, it wants you to tell it what class to use for java.naming.factory.initial. What is your runtime platform? How you bind resources into JNDI is determined by your runtime platform. Furthermore, many if not most platforms provide a means to pool connections. Both JBoss and Tomcat do, so constructing a pooled connection in those environments is as simple as defining them in a configuration file, then looking them up in your code. -- Guy Rouillier