You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by U K Laxmi <la...@yahoo.com> on 2005/02/19 07:47:06 UTC

Name jdbc is not bound in this Context error

I could able to get thro' JarperException. Thanks for
replies.

Now facing new problem.

I'm getting "NameNotFoundException" -  Name jdbc is
not bound in this Context 

Environment what i'm using is: Apache 2, Tomcat 5.5,
Netscape 7.2, MsAccess 2003 on windows 2000 machine.

I integrated tomcat and apache as apache doesn't
support jsps. I wrote a JSP called test-db.jsp which
in turn calls java program TestSQLLoad.java. This
TestSQLLoad.java performs dattabase operation, fetches
the data from table and that data is displayed on
Netscape thro' jsp. 

1. test-db.jsp resides ina directory
TOMCAT_HOME/webapps/web/JSP. Contents are as follows:

<%@ page contentType="text/html"
import="testpkg.TestSQLLoad"%>

	<html>
      <head>
        <title>DB Test</title>
      </head>
      <body>

      <%
        TestSQLLoad tst = new TestSQLLoad();
        tst.init();
      %>

      <h2>Results</h2>
        User -> <%= tst.getUser() %><br/>
        Pwd -> <%= tst.getPassword() %><br/>
        Id -> <%= tst.getID() %>

      </body>
    </html>

2. TestSQLLoad.java is residing in following
directory. TOMCAT_HOME/webapps/web/classes/testpkg
direcotry. Contents of this file are as follows:

	package testpkg;

	import javax.naming.*;
    import javax.sql.*;
    import java.sql.*;

    public class TestSQLLoad
    {
      
     String user = "Not Connected";
     String pwd = "no pwd";
     int id = -1;
     
     public void init() {
      try{
       Context ctx = new InitialContext();
       if(ctx == null ) {
        throw new Exception("Boom - No Context");
       }

	   Context envCtx = (Context)
ctx.lookup("java:comp/env");
       DataSource ds = (DataSource)
envCtx.lookup("jdbc/db1");

       //DataSource ds =
(DataSource)ctx.lookup("java:comp/env/jdbc/db1");

       if (ds != null) {
        Connection conn = ds.getConnection();
        
        if(conn != null) {
         user = "Got Connection "+conn.toString();
         Statement stmt = conn.createStatement();
         String q = "select name, password, id from
user";
         ResultSet rst = stmt.executeQuery(q);
         if(rst.next()) {
          user=rst.getString(1);
          pwd=rst.getString(2);
          id = rst.getInt(3);
         }
         conn.close();
        }
       }
      }catch(Exception e) {
       e.printStackTrace();
      }
     }

     public String getUser() {
      return user;
     }
     
     public String getPassword() {
      return pwd;
     }
     
     public int getID()
     {
      return id;
     }
    }

3. I created a jar file using testpkg directory & put
it in TOMCAT_HOME/common/lib as well as
TOMCAT_HOME/webapps/web/WEB-INF/lib directory.

4. I created MsAccess database called db1.mdb and put
it in TOMCAT_HOME/WEBAPPS/WEB/db1 directory. I created
a table called user with fields name, password and ID.
ID is the primary key.

5. I included following in the server.xml of
TOMCAT_HOME/conf directory.

<Context path="/db1" docBase="C:/tomcat/webapps/db1"
            debug="5" reloadable="true"
crossContext="true">

<GlobalNamingResources>
  <Resource name="jdbc/db1" auth="Container"
    type="javax.sql.DataSource"

factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
    driverClassName="sun.jdbc.odbc.JdbcOdbcDrive"
    url="jdbc:odbc://localhost/db1"
	maxActive="20" maxIdle="10" maxWait="-1" />
	</GlobalNamingResources>
</Context>

6. I included following in context.xml of
TOMCAT_HOME/conf directory.

<ResourceLink global="jdbc/db1" name="jdbc/db1"
type="javax.sql.DataSource"/>

7. I included following in web.xml of
TOMCAT_HOME/webapps/web/WEB-INF directory.

   <resource-ref>
        <res-ref-name>jdbc/db1</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
    </resource-ref>

8. I copied commons-collections-2.1.1.jar,
commons-dbcp-1.2.1.jar and commons-pool-1.2.jar into
TOMCAT_HOME/common/lib directory.

9. I started apache, tomcat and then opened a browser
and typed http://localhost/web/JSP/test-db.jsp.

10. I get following on the browser.

"Results
User -> Not Connected
Pwd -> no pwd
Id -> -1"

11. On the tomcat window where tomcat is running i'm
getting following error.

javax.naming.NameNotFoundException: Name jdbc is not
bound in this Context
        at
org.apache.naming.NamingContext.lookup(NamingContext.java:769)
        at
org.apache.naming.NamingContext.lookup(NamingContext.java:152)
        at
org.apache.naming.factory.ResourceLinkFactory.getObjectInstance(Resou
rceLinkFactory.java:96)
        at
javax.naming.spi.NamingManager.getObjectInstance(Unknown
Source)
        at
org.apache.naming.NamingContext.lookup(NamingContext.java:792)
        at
org.apache.naming.NamingContext.lookup(NamingContext.java:139)
        at
org.apache.naming.NamingContext.lookup(NamingContext.java:780)
        at
org.apache.naming.NamingContext.lookup(NamingContext.java:152)
        at
testpkg.TestSQLLoad.init(TestSQLLoad.java:22)
        at
org.apache.jsp.JSP.test_002ddb_jsp._jspService(org.apache.jsp.JSP.tes
t_002ddb_jsp:54)
        at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99)
        at
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper
.java:325)
        at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:2
95)
        at
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
        at
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:252)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:173)
        at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:214)
        at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:178)
        at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:126)
        at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:105)
        at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:107)
        at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:148)
        at
org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:306)

        at
org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:385)
        at
org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:745)
        at
org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.ja
va:675)
        at
org.apache.jk.common.SocketConnection.runIt(ChannelSocket.java:868)
        at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP
ool.java:684)
        at java.lang.Thread.run(Unknown Source)

11. Actually if i see the source code of TestSQLLoad
it's throwing error on line 22 where it's trying to
get  datasource.

I've rpovided all the information that i can. Please
help to solve my problem and connect to database thro'
jsp successfully. Any help in this regard is highly
appreciated.

Thanks in advance.


		
__________________________________ 
Do you Yahoo!? 
The all-new My Yahoo! - What will yours do?
http://my.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Name jdbc is not bound in this Context error

Posted by Antony Paul <an...@gmail.com>.
In fact I hadnt installed it in windlws. You can connect to server
suing psql. it will be in the bin directory. There is one GUI front
end available PgAdmin. The documentation will be in doc directory.
This contains installation, administration and tutorials on SQL. For
further you can ask questions at PostgreSQL mailing
lists(http://www.postgresql.org/community/lists/).

rgds
Antony Paul



On Tue, 22 Feb 2005 02:07:20 -0800 (PST), U K Laxmi <la...@yahoo.com> wrote:
> Hi Antony,
> 
> I downloaded postgres and installed on my m/c. I
> installed it as a service.
> 
> Can you pls give step by step instruction as how to
> connect to postgresql database.
> 
> Thank you so much.
> 
> --- Antony Paul <an...@gmail.com> wrote:
> 
> > You can name it the name of the context(web). The
> > content should be
> > similar to any other file there. I am giving a
> > sample
> >
> > <Context docBase="${catalina.home}/webapps/web"
> >          antiResourceLocking="false"
> > antiJARLocking="false">
> >
> > </Context>
> >
> > rgds
> > Antony Paul
> >
> >
> > On Mon, 21 Feb 2005 23:18:55 -0800 (PST), U K Laxmi
> > <la...@yahoo.com> wrote:
> > > Thanks for the replies. What do u mean by the
> > > following in ur erlier mail.
> > > > > >
> > > > > > Did you defined your newly created context
> > web
> > > > in
> > > > > > server.xml or at
> > > > > > TOMCAT_HOME\conf\Catalina\localhost\some
> > > > name.xml
> > > > > >
> > >
> > > Does it mean i need to create a new xml file in
> > > TOMCAT_HOME\conf\Catalina\localhost? What should
> > be
> > > it's name? What should it contain? Pls let me
> > know. I
> > > will try that. I didn't create any file there.
> > >
> > > Thanks again.
> > >
> > > > > > hope it will help.
> > > > > >
> > > > > > rgds
> > > > > > Antony Paul
> > > > > >
> > > > > >
> > > > > >
> > > > > > On Mon, 21 Feb 2005 22:25:59 -0800 (PST), U
> > K
> > > > Laxmi
> > > > > > <la...@yahoo.com> wrote:
> > > > > > > Yes i read and did as per the document.
> > When
> > > > it
> > > > > > didn't
> > > > > > > work, i followed the suggetions given to
> > many
> > > > > > users in
> > > > > > > the mailing lists in the internet and now
> > i
> > > > guess
> > > > > > i
> > > > > > > messed up. Actually in the error, it says,
> > no
> > > > > > suitable
> > > > > > > driver found.
> > > > > > >
> > > > > > > I'm using Ms Access as it's free. Do we
> > have
> > > > any
> > > > > > free
> > > > > > > driver available in the form of jar to use
> > in
> > > > > > place of
> > > > > > > JDBC-ODBC bridge driver? Or it's not
> > required
> > > > if
> > > > > > > configuration is correct. Pls let me know.
> > > > I've
> > > > > > pasted
> > > > > > > all relevant code in my first mail itself.
> > If
> > > > time
> > > > > > > permits, any of you can try & give me the
> > > > > > solution.
> > > > > > > It'll be a great help.
> > > > > > >
> > > > > > > I've integrated tomcat 5.5.7 with apache
> > 2.
> > > > Does
> > > > > > this
> > > > > > > has any impact on the above.
> > > > > > >
> > > > > > > --- Antony Paul <an...@gmail.com>
> > > > wrote:
> > > > > > >
> > > > > > > > If you followed the tomcat docs you will
> > > > have no
> > > > > > > > problem in DBCP
> > > > > > > > getting to work. Going for
> > > > Globalnamingresources
> > > > > > is
> > > > > > > > needed if you need
> > > > > > > > to access it will all applications. Try
> > to
> > > > > > configure
> > > > > > > > it as per the doc
> > > > > > > > in following URL.
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples-howto.html
> > > > > > > >
> > > > > > > > follow MySQL config. And no need to put
> > > > > > commons*.jar
> > > > > > > > in commons/lib as
> > > > > > > > TC by default comes with it.
> > > > > > > >
> > > > > > > > rgds
> > > > > > > > Antony Paul
> > > > > > > >
> > > > > > > >
> > > > > > > > On Mon, 21 Feb 2005 21:52:13 -0800
> > (PST), U
> > > > K
> > > > > > Laxmi
> > > > > > > > <la...@yahoo.com> wrote:
> > > > > > > > > I tried without GlobalNamingResources.
> > No
> > > > > > luck.
> > > > > > > > When
> > > > > > > > > googled, i found that if we include
> > > > > > > > > GlobalNamingResource tag, then it will
> > be
> > > > > > > > available in
> > > > > > > > > all web context.
> > > > > > > > >
> > > > > > > > > After spending enough time on that,
> > now i
> > > >
> > > === message truncated ===
> > >
> > > __________________________________
> > > Do you Yahoo!?
> > > Yahoo! Mail - Helps protect you from nasty
> > viruses.
> > > http://promotions.yahoo.com/new_mail
> > >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > tomcat-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> > tomcat-user-help@jakarta.apache.org
> >
> >
> 
> __________________________________
> Do you Yahoo!?
> The all-new My Yahoo! - What will yours do?
> http://my.yahoo.com
>

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Name jdbc is not bound in this Context error

Posted by U K Laxmi <la...@yahoo.com>.
Hi Antony,

I downloaded postgres and installed on my m/c. I
installed it as a service. 

Can you pls give step by step instruction as how to
connect to postgresql database.

Thank you so much.

--- Antony Paul <an...@gmail.com> wrote:

> You can name it the name of the context(web). The
> content should be
> similar to any other file there. I am giving a
> sample
> 
> <Context docBase="${catalina.home}/webapps/web"
>          antiResourceLocking="false"
> antiJARLocking="false">
> 
> </Context>
> 
> rgds
> Antony Paul
> 
> 
> On Mon, 21 Feb 2005 23:18:55 -0800 (PST), U K Laxmi
> <la...@yahoo.com> wrote:
> > Thanks for the replies. What do u mean by the
> > following in ur erlier mail.
> > > > >
> > > > > Did you defined your newly created context
> web
> > > in
> > > > > server.xml or at
> > > > > TOMCAT_HOME\conf\Catalina\localhost\some
> > > name.xml
> > > > >
> > 
> > Does it mean i need to create a new xml file in
> > TOMCAT_HOME\conf\Catalina\localhost? What should
> be
> > it's name? What should it contain? Pls let me
> know. I
> > will try that. I didn't create any file there.
> > 
> > Thanks again.
> > 
> > > > > hope it will help.
> > > > >
> > > > > rgds
> > > > > Antony Paul
> > > > >
> > > > >
> > > > >
> > > > > On Mon, 21 Feb 2005 22:25:59 -0800 (PST), U
> K
> > > Laxmi
> > > > > <la...@yahoo.com> wrote:
> > > > > > Yes i read and did as per the document.
> When
> > > it
> > > > > didn't
> > > > > > work, i followed the suggetions given to
> many
> > > > > users in
> > > > > > the mailing lists in the internet and now
> i
> > > guess
> > > > > i
> > > > > > messed up. Actually in the error, it says,
> no
> > > > > suitable
> > > > > > driver found.
> > > > > >
> > > > > > I'm using Ms Access as it's free. Do we
> have
> > > any
> > > > > free
> > > > > > driver available in the form of jar to use
> in
> > > > > place of
> > > > > > JDBC-ODBC bridge driver? Or it's not
> required
> > > if
> > > > > > configuration is correct. Pls let me know.
> > > I've
> > > > > pasted
> > > > > > all relevant code in my first mail itself.
> If
> > > time
> > > > > > permits, any of you can try & give me the
> > > > > solution.
> > > > > > It'll be a great help.
> > > > > >
> > > > > > I've integrated tomcat 5.5.7 with apache
> 2.
> > > Does
> > > > > this
> > > > > > has any impact on the above.
> > > > > >
> > > > > > --- Antony Paul <an...@gmail.com>
> > > wrote:
> > > > > >
> > > > > > > If you followed the tomcat docs you will
> > > have no
> > > > > > > problem in DBCP
> > > > > > > getting to work. Going for
> > > Globalnamingresources
> > > > > is
> > > > > > > needed if you need
> > > > > > > to access it will all applications. Try
> to
> > > > > configure
> > > > > > > it as per the doc
> > > > > > > in following URL.
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples-howto.html
> > > > > > >
> > > > > > > follow MySQL config. And no need to put
> > > > > commons*.jar
> > > > > > > in commons/lib as
> > > > > > > TC by default comes with it.
> > > > > > >
> > > > > > > rgds
> > > > > > > Antony Paul
> > > > > > >
> > > > > > >
> > > > > > > On Mon, 21 Feb 2005 21:52:13 -0800
> (PST), U
> > > K
> > > > > Laxmi
> > > > > > > <la...@yahoo.com> wrote:
> > > > > > > > I tried without GlobalNamingResources.
> No
> > > > > luck.
> > > > > > > When
> > > > > > > > googled, i found that if we include
> > > > > > > > GlobalNamingResource tag, then it will
> be
> > > > > > > available in
> > > > > > > > all web context.
> > > > > > > >
> > > > > > > > After spending enough time on that,
> now i
> > >
> > === message truncated ===
> > 
> > __________________________________
> > Do you Yahoo!?
> > Yahoo! Mail - Helps protect you from nasty
> viruses.
> > http://promotions.yahoo.com/new_mail
> >
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> tomcat-user-help@jakarta.apache.org
> 
> 



		
__________________________________ 
Do you Yahoo!? 
The all-new My Yahoo! - What will yours do?
http://my.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Name jdbc is not bound in this Context error

Posted by Antony Paul <an...@gmail.com>.
You can name it the name of the context(web). The content should be
similar to any other file there. I am giving a sample

<Context docBase="${catalina.home}/webapps/web"
         antiResourceLocking="false" antiJARLocking="false">

</Context>

rgds
Antony Paul


On Mon, 21 Feb 2005 23:18:55 -0800 (PST), U K Laxmi <la...@yahoo.com> wrote:
> Thanks for the replies. What do u mean by the
> following in ur erlier mail.
> > > >
> > > > Did you defined your newly created context web
> > in
> > > > server.xml or at
> > > > TOMCAT_HOME\conf\Catalina\localhost\some
> > name.xml
> > > >
> 
> Does it mean i need to create a new xml file in
> TOMCAT_HOME\conf\Catalina\localhost? What should be
> it's name? What should it contain? Pls let me know. I
> will try that. I didn't create any file there.
> 
> Thanks again.
> 
> > > > hope it will help.
> > > >
> > > > rgds
> > > > Antony Paul
> > > >
> > > >
> > > >
> > > > On Mon, 21 Feb 2005 22:25:59 -0800 (PST), U K
> > Laxmi
> > > > <la...@yahoo.com> wrote:
> > > > > Yes i read and did as per the document. When
> > it
> > > > didn't
> > > > > work, i followed the suggetions given to many
> > > > users in
> > > > > the mailing lists in the internet and now i
> > guess
> > > > i
> > > > > messed up. Actually in the error, it says, no
> > > > suitable
> > > > > driver found.
> > > > >
> > > > > I'm using Ms Access as it's free. Do we have
> > any
> > > > free
> > > > > driver available in the form of jar to use in
> > > > place of
> > > > > JDBC-ODBC bridge driver? Or it's not required
> > if
> > > > > configuration is correct. Pls let me know.
> > I've
> > > > pasted
> > > > > all relevant code in my first mail itself. If
> > time
> > > > > permits, any of you can try & give me the
> > > > solution.
> > > > > It'll be a great help.
> > > > >
> > > > > I've integrated tomcat 5.5.7 with apache 2.
> > Does
> > > > this
> > > > > has any impact on the above.
> > > > >
> > > > > --- Antony Paul <an...@gmail.com>
> > wrote:
> > > > >
> > > > > > If you followed the tomcat docs you will
> > have no
> > > > > > problem in DBCP
> > > > > > getting to work. Going for
> > Globalnamingresources
> > > > is
> > > > > > needed if you need
> > > > > > to access it will all applications. Try to
> > > > configure
> > > > > > it as per the doc
> > > > > > in following URL.
> > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples-howto.html
> > > > > >
> > > > > > follow MySQL config. And no need to put
> > > > commons*.jar
> > > > > > in commons/lib as
> > > > > > TC by default comes with it.
> > > > > >
> > > > > > rgds
> > > > > > Antony Paul
> > > > > >
> > > > > >
> > > > > > On Mon, 21 Feb 2005 21:52:13 -0800 (PST), U
> > K
> > > > Laxmi
> > > > > > <la...@yahoo.com> wrote:
> > > > > > > I tried without GlobalNamingResources. No
> > > > luck.
> > > > > > When
> > > > > > > googled, i found that if we include
> > > > > > > GlobalNamingResource tag, then it will be
> > > > > > available in
> > > > > > > all web context.
> > > > > > >
> > > > > > > After spending enough time on that, now i
> >
> === message truncated ===
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail - Helps protect you from nasty viruses.
> http://promotions.yahoo.com/new_mail
>

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Name jdbc is not bound in this Context error

Posted by U K Laxmi <la...@yahoo.com>.
Thanks for the replies. What do u mean by the
following in ur erlier mail.
> > >
> > > Did you defined your newly created context web
> in
> > > server.xml or at
> > > TOMCAT_HOME\conf\Catalina\localhost\some
> name.xml
> > >

Does it mean i need to create a new xml file in
TOMCAT_HOME\conf\Catalina\localhost? What should be
it's name? What should it contain? Pls let me know. I
will try that. I didn't create any file there.

Thanks again.

> > > hope it will help.
> > >
> > > rgds
> > > Antony Paul
> > >
> > >
> > >
> > > On Mon, 21 Feb 2005 22:25:59 -0800 (PST), U K
> Laxmi
> > > <la...@yahoo.com> wrote:
> > > > Yes i read and did as per the document. When
> it
> > > didn't
> > > > work, i followed the suggetions given to many
> > > users in
> > > > the mailing lists in the internet and now i
> guess
> > > i
> > > > messed up. Actually in the error, it says, no
> > > suitable
> > > > driver found.
> > > >
> > > > I'm using Ms Access as it's free. Do we have
> any
> > > free
> > > > driver available in the form of jar to use in
> > > place of
> > > > JDBC-ODBC bridge driver? Or it's not required
> if
> > > > configuration is correct. Pls let me know.
> I've
> > > pasted
> > > > all relevant code in my first mail itself. If
> time
> > > > permits, any of you can try & give me the
> > > solution.
> > > > It'll be a great help.
> > > >
> > > > I've integrated tomcat 5.5.7 with apache 2.
> Does
> > > this
> > > > has any impact on the above.
> > > >
> > > > --- Antony Paul <an...@gmail.com>
> wrote:
> > > >
> > > > > If you followed the tomcat docs you will
> have no
> > > > > problem in DBCP
> > > > > getting to work. Going for
> Globalnamingresources
> > > is
> > > > > needed if you need
> > > > > to access it will all applications. Try to
> > > configure
> > > > > it as per the doc
> > > > > in following URL.
> > > > >
> > > > >
> > > >
> > >
> >
>
http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples-howto.html
> > > > >
> > > > > follow MySQL config. And no need to put
> > > commons*.jar
> > > > > in commons/lib as
> > > > > TC by default comes with it.
> > > > >
> > > > > rgds
> > > > > Antony Paul
> > > > >
> > > > >
> > > > > On Mon, 21 Feb 2005 21:52:13 -0800 (PST), U
> K
> > > Laxmi
> > > > > <la...@yahoo.com> wrote:
> > > > > > I tried without GlobalNamingResources. No
> > > luck.
> > > > > When
> > > > > > googled, i found that if we include
> > > > > > GlobalNamingResource tag, then it will be
> > > > > available in
> > > > > > all web context.
> > > > > >
> > > > > > After spending enough time on that, now i
> 
=== message truncated ===



		
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - Helps protect you from nasty viruses. 
http://promotions.yahoo.com/new_mail

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Name jdbc is not bound in this Context error

Posted by Antony Paul <an...@gmail.com>.
Most SQL is same and it supports a subset of SQL 92 and SQL 99
standards. Every RDBMS vendor  have some proprietory code which dont
work in other databases. There is one RDBMS
Firebird(http://firebird.sourceforge.net/). The site claims that it is
more like Oracle.

rgds
Antony Paul


On Mon, 21 Feb 2005 23:01:40 -0800 (PST), U K Laxmi <la...@yahoo.com> wrote:
> Thank you for the replies. Ms Access is not a
> relational databaase. It's just DBMS. I didn't know
> that PostGreSQL is a open source RDBMS system. All the
> sqls, table creation etc.. works similar to Oracle or
> any other RDBMS? I'm working on windows 2000 machine.
> 
> --- Antony Paul <an...@gmail.com> wrote:
> 
> > I dont whether MS Access is considered as RDBMS. For
> > serious
> > development it is not recommended. Using ODBC have
> > several problems. I
> > will recommend PostgreSQL. Now it runs very well on
> > Windows. But
> > requires Windows 2000 or higher. You can find it at
> > http://www.postgresql.org/ftp/binary/v8.0.1/win32/.
> >     I am using it and have no problems. I am posting
> > my configuration
> > that I used to set up DBCP.
> >
> > server.xml
> > -----------------------------------
> > <GlobalNamingResources>
> >
> >     <!-- Test entry for demonstration purposes -->
> >     <Environment name="simpleValue"
> > type="java.lang.Integer" value="30"/>
> >
> >     <!-- Editable user database that can also be
> > used by
> >          UserDatabaseRealm to authenticate users -->
> >     <Resource name="UserDatabase" auth="Container"
> >
> > type="org.apache.catalina.UserDatabase"
> >        description="User database that can be
> > updated and saved"
> >
> >
> factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
> >           pathname="conf/tomcat-users.xml" />
> >
> >           <Resource name="jdbc/db1" auth="Container"
> >             type="javax.sql.DataSource"
> >
> >
> factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
> >             driverClassName="org.postgresql.Driver"
> >
> > url="jdbc:postgresql://192.168.4.248/antony"
> >             maxActive="20" maxIdle="10" maxWait="-1"
> >
> >             username="benchmark"
> > password="benchmark"
> >             />
> >
> >   </GlobalNamingResources>
> >
> >
> > TOMCAT_HOME/conf/context.xml
> > ---------------------------------------------------
> > <ResourceLink global="jdbc/db1" name="jdbc/db1"
> > type="javax.sql.DataSource"/>
> >
> > TOMCAT_HOME/webapps/web/WEB-INF/web.xml
> >
> -----------------------------------------------------------------------------
> > <resource-ref>
> >       <res-ref-name>jdbc/db1</res-ref-name>
> >       <res-type>javax.sql.DataSource</res-type>
> >       <res-auth>Container</res-auth>
> >   </resource-ref>
> >
> >
> >
> > Did you defined your newly created context web in
> > server.xml or at
> > TOMCAT_HOME\conf\Catalina\localhost\some name.xml
> >
> > hope it will help.
> >
> > rgds
> > Antony Paul
> >
> >
> >
> > On Mon, 21 Feb 2005 22:25:59 -0800 (PST), U K Laxmi
> > <la...@yahoo.com> wrote:
> > > Yes i read and did as per the document. When it
> > didn't
> > > work, i followed the suggetions given to many
> > users in
> > > the mailing lists in the internet and now i guess
> > i
> > > messed up. Actually in the error, it says, no
> > suitable
> > > driver found.
> > >
> > > I'm using Ms Access as it's free. Do we have any
> > free
> > > driver available in the form of jar to use in
> > place of
> > > JDBC-ODBC bridge driver? Or it's not required if
> > > configuration is correct. Pls let me know. I've
> > pasted
> > > all relevant code in my first mail itself. If time
> > > permits, any of you can try & give me the
> > solution.
> > > It'll be a great help.
> > >
> > > I've integrated tomcat 5.5.7 with apache 2. Does
> > this
> > > has any impact on the above.
> > >
> > > --- Antony Paul <an...@gmail.com> wrote:
> > >
> > > > If you followed the tomcat docs you will have no
> > > > problem in DBCP
> > > > getting to work. Going for Globalnamingresources
> > is
> > > > needed if you need
> > > > to access it will all applications. Try to
> > configure
> > > > it as per the doc
> > > > in following URL.
> > > >
> > > >
> > >
> >
> http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples-howto.html
> > > >
> > > > follow MySQL config. And no need to put
> > commons*.jar
> > > > in commons/lib as
> > > > TC by default comes with it.
> > > >
> > > > rgds
> > > > Antony Paul
> > > >
> > > >
> > > > On Mon, 21 Feb 2005 21:52:13 -0800 (PST), U K
> > Laxmi
> > > > <la...@yahoo.com> wrote:
> > > > > I tried without GlobalNamingResources. No
> > luck.
> > > > When
> > > > > googled, i found that if we include
> > > > > GlobalNamingResource tag, then it will be
> > > > available in
> > > > > all web context.
> > > > >
> > > > > After spending enough time on that, now i
> > coded
> > > > all
> > > > > database related stuff in JSP in the way we do
> > in
> > > > > stand alone application. I mean -
> > > > >
> > > > > Coding like this in jspo itself.
> > > > >
> > > > > ---- code --
> > > > > <%@ page contentType="text/html"
> > > > import="java.sql.*"%>
> > > > >
> > > > >  <html>
> > > > >
> > > > >  <head><title>simmPlan - simple material
> > planning
> > > > > system</title>
> > > > > <script language="JavaScript"
> > > > > src="/js/default.js"></script>
> > > > >
> > > > >  <%
> > > > >
> > > > >   String userid =
> > request.getParameter("userid");
> > > > >   String passwd =
> > request.getParameter("passwd");
> > > > >   System.out.println("Password: " + passwd);
> > > > >   String pwd = "", str = "";
> > > > >   int level = -1, ind = -1;
> > > > >
> > > > > try {
> > > > >                 Connection conn = null;
> > > > >
> > > > Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
> > > > >
> > > > >
> > > >
> > >
> >
> conn=DriverManager.getConnection("jdbc:odbc:driver={Microsoft
> > > > > Access Driver
> > > > > (*.mdb)};DBQ=C:/tomcat/webapps/db1/db1.mdb");
> > > > >                 Statement stmt =
> > > > > conn.createStatement();
> > > > >
> > > > >                 String query = "SELECT * FROM
> > user
> > > > > where name = '" + userid + "'";
> > > > >
> > > > >                 ResultSet st =
> > > > > stmt.executeQuery(query);
> > > > >                 if (st.next()) {
> > > > >                     pwd =
> > > > st.getString("password");
> > > > >
> > > > >                                         level
> > =
> > > > st.getInt("level");
> > > > >                     System.err.println("Query
> > > > > result="+userid+"/"+pwd+"/"+level);
> > > > >                 }
> > > > >                                 else {
> > > > >                                         ind =
> > -2;
> >
> === message truncated ===
> 
> __________________________________
> Do you Yahoo!?
> The all-new My Yahoo! - Get yours free!
> http://my.yahoo.com
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Name jdbc is not bound in this Context error

Posted by U K Laxmi <la...@yahoo.com>.
Thank you for the replies. Ms Access is not a
relational databaase. It's just DBMS. I didn't know
that PostGreSQL is a open source RDBMS system. All the
sqls, table creation etc.. works similar to Oracle or
any other RDBMS? I'm working on windows 2000 machine. 

--- Antony Paul <an...@gmail.com> wrote:

> I dont whether MS Access is considered as RDBMS. For
> serious
> development it is not recommended. Using ODBC have
> several problems. I
> will recommend PostgreSQL. Now it runs very well on
> Windows. But
> requires Windows 2000 or higher. You can find it at
> http://www.postgresql.org/ftp/binary/v8.0.1/win32/. 
>     I am using it and have no problems. I am posting
> my configuration
> that I used to set up DBCP.
> 
> server.xml
> -----------------------------------
> <GlobalNamingResources>
> 
>     <!-- Test entry for demonstration purposes -->
>     <Environment name="simpleValue"
> type="java.lang.Integer" value="30"/>
> 
>     <!-- Editable user database that can also be
> used by
>          UserDatabaseRealm to authenticate users -->
>     <Resource name="UserDatabase" auth="Container"
>              
> type="org.apache.catalina.UserDatabase"
>        description="User database that can be
> updated and saved"
>           
>
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
>           pathname="conf/tomcat-users.xml" />
>           
>           <Resource name="jdbc/db1" auth="Container"
>             type="javax.sql.DataSource" 
>            
>
factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
>             driverClassName="org.postgresql.Driver"
>            
> url="jdbc:postgresql://192.168.4.248/antony"
>             maxActive="20" maxIdle="10" maxWait="-1"
> 
>             username="benchmark"
> password="benchmark"
>             />
> 
>   </GlobalNamingResources>
> 
> 
> TOMCAT_HOME/conf/context.xml
> ---------------------------------------------------
> <ResourceLink global="jdbc/db1" name="jdbc/db1"
> type="javax.sql.DataSource"/>
> 
> TOMCAT_HOME/webapps/web/WEB-INF/web.xml
>
-----------------------------------------------------------------------------
> <resource-ref>
>       <res-ref-name>jdbc/db1</res-ref-name>
>       <res-type>javax.sql.DataSource</res-type>
>       <res-auth>Container</res-auth>
>   </resource-ref>
> 
> 
> 
> Did you defined your newly created context web in
> server.xml or at
> TOMCAT_HOME\conf\Catalina\localhost\some name.xml
> 
> hope it will help. 
> 
> rgds
> Antony Paul
> 
> 
> 
> On Mon, 21 Feb 2005 22:25:59 -0800 (PST), U K Laxmi
> <la...@yahoo.com> wrote:
> > Yes i read and did as per the document. When it
> didn't
> > work, i followed the suggetions given to many
> users in
> > the mailing lists in the internet and now i guess
> i
> > messed up. Actually in the error, it says, no
> suitable
> > driver found.
> > 
> > I'm using Ms Access as it's free. Do we have any
> free
> > driver available in the form of jar to use in
> place of
> > JDBC-ODBC bridge driver? Or it's not required if
> > configuration is correct. Pls let me know. I've
> pasted
> > all relevant code in my first mail itself. If time
> > permits, any of you can try & give me the
> solution.
> > It'll be a great help.
> > 
> > I've integrated tomcat 5.5.7 with apache 2. Does
> this
> > has any impact on the above.
> > 
> > --- Antony Paul <an...@gmail.com> wrote:
> > 
> > > If you followed the tomcat docs you will have no
> > > problem in DBCP
> > > getting to work. Going for Globalnamingresources
> is
> > > needed if you need
> > > to access it will all applications. Try to
> configure
> > > it as per the doc
> > > in following URL.
> > >
> > >
> >
>
http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples-howto.html
> > >
> > > follow MySQL config. And no need to put
> commons*.jar
> > > in commons/lib as
> > > TC by default comes with it.
> > >
> > > rgds
> > > Antony Paul
> > >
> > >
> > > On Mon, 21 Feb 2005 21:52:13 -0800 (PST), U K
> Laxmi
> > > <la...@yahoo.com> wrote:
> > > > I tried without GlobalNamingResources. No
> luck.
> > > When
> > > > googled, i found that if we include
> > > > GlobalNamingResource tag, then it will be
> > > available in
> > > > all web context.
> > > >
> > > > After spending enough time on that, now i
> coded
> > > all
> > > > database related stuff in JSP in the way we do
> in
> > > > stand alone application. I mean -
> > > >
> > > > Coding like this in jspo itself.
> > > >
> > > > ---- code --
> > > > <%@ page contentType="text/html"
> > > import="java.sql.*"%>
> > > >
> > > >  <html>
> > > >
> > > >  <head><title>simmPlan - simple material
> planning
> > > > system</title>
> > > > <script language="JavaScript"
> > > > src="/js/default.js"></script>
> > > >
> > > >  <%
> > > >
> > > >   String userid =
> request.getParameter("userid");
> > > >   String passwd =
> request.getParameter("passwd");
> > > >   System.out.println("Password: " + passwd);
> > > >   String pwd = "", str = "";
> > > >   int level = -1, ind = -1;
> > > >
> > > > try {
> > > >                 Connection conn = null;
> > > >
> > > Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
> > > >
> > > >
> > >
> >
>
conn=DriverManager.getConnection("jdbc:odbc:driver={Microsoft
> > > > Access Driver
> > > > (*.mdb)};DBQ=C:/tomcat/webapps/db1/db1.mdb");
> > > >                 Statement stmt =
> > > > conn.createStatement();
> > > >
> > > >                 String query = "SELECT * FROM
> user
> > > > where name = '" + userid + "'";
> > > >
> > > >                 ResultSet st =
> > > > stmt.executeQuery(query);
> > > >                 if (st.next()) {
> > > >                     pwd =
> > > st.getString("password");
> > > >
> > > >                                         level
> =
> > > st.getInt("level");
> > > >                     System.err.println("Query
> > > > result="+userid+"/"+pwd+"/"+level);
> > > >                 }
> > > >                                 else {
> > > >                                         ind =
> -2;
> 
=== message truncated ===



		
__________________________________ 
Do you Yahoo!? 
The all-new My Yahoo! - Get yours free! 
http://my.yahoo.com 
 


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Name jdbc is not bound in this Context error

Posted by Antony Paul <an...@gmail.com>.
I dont whether MS Access is considered as RDBMS. For serious
development it is not recommended. Using ODBC have several problems. I
will recommend PostgreSQL. Now it runs very well on Windows. But
requires Windows 2000 or higher. You can find it at
http://www.postgresql.org/ftp/binary/v8.0.1/win32/. 
    I am using it and have no problems. I am posting my configuration
that I used to set up DBCP.

server.xml
-----------------------------------
<GlobalNamingResources>

    <!-- Test entry for demonstration purposes -->
    <Environment name="simpleValue" type="java.lang.Integer" value="30"/>

    <!-- Editable user database that can also be used by
         UserDatabaseRealm to authenticate users -->
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
       description="User database that can be updated and saved"
           factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
          pathname="conf/tomcat-users.xml" />
          
          <Resource name="jdbc/db1" auth="Container"
            type="javax.sql.DataSource" 
            factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
            driverClassName="org.postgresql.Driver"
            url="jdbc:postgresql://192.168.4.248/antony"
            maxActive="20" maxIdle="10" maxWait="-1" 
            username="benchmark" password="benchmark"
            />

  </GlobalNamingResources>


TOMCAT_HOME/conf/context.xml
---------------------------------------------------
<ResourceLink global="jdbc/db1" name="jdbc/db1" type="javax.sql.DataSource"/>

TOMCAT_HOME/webapps/web/WEB-INF/web.xml
-----------------------------------------------------------------------------
<resource-ref>
      <res-ref-name>jdbc/db1</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
  </resource-ref>



Did you defined your newly created context web in server.xml or at
TOMCAT_HOME\conf\Catalina\localhost\some name.xml

hope it will help. 

rgds
Antony Paul



On Mon, 21 Feb 2005 22:25:59 -0800 (PST), U K Laxmi <la...@yahoo.com> wrote:
> Yes i read and did as per the document. When it didn't
> work, i followed the suggetions given to many users in
> the mailing lists in the internet and now i guess i
> messed up. Actually in the error, it says, no suitable
> driver found.
> 
> I'm using Ms Access as it's free. Do we have any free
> driver available in the form of jar to use in place of
> JDBC-ODBC bridge driver? Or it's not required if
> configuration is correct. Pls let me know. I've pasted
> all relevant code in my first mail itself. If time
> permits, any of you can try & give me the solution.
> It'll be a great help.
> 
> I've integrated tomcat 5.5.7 with apache 2. Does this
> has any impact on the above.
> 
> --- Antony Paul <an...@gmail.com> wrote:
> 
> > If you followed the tomcat docs you will have no
> > problem in DBCP
> > getting to work. Going for Globalnamingresources is
> > needed if you need
> > to access it will all applications. Try to configure
> > it as per the doc
> > in following URL.
> >
> >
> http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples-howto.html
> >
> > follow MySQL config. And no need to put commons*.jar
> > in commons/lib as
> > TC by default comes with it.
> >
> > rgds
> > Antony Paul
> >
> >
> > On Mon, 21 Feb 2005 21:52:13 -0800 (PST), U K Laxmi
> > <la...@yahoo.com> wrote:
> > > I tried without GlobalNamingResources. No luck.
> > When
> > > googled, i found that if we include
> > > GlobalNamingResource tag, then it will be
> > available in
> > > all web context.
> > >
> > > After spending enough time on that, now i coded
> > all
> > > database related stuff in JSP in the way we do in
> > > stand alone application. I mean -
> > >
> > > Coding like this in jspo itself.
> > >
> > > ---- code --
> > > <%@ page contentType="text/html"
> > import="java.sql.*"%>
> > >
> > >  <html>
> > >
> > >  <head><title>simmPlan - simple material planning
> > > system</title>
> > > <script language="JavaScript"
> > > src="/js/default.js"></script>
> > >
> > >  <%
> > >
> > >   String userid = request.getParameter("userid");
> > >   String passwd = request.getParameter("passwd");
> > >   System.out.println("Password: " + passwd);
> > >   String pwd = "", str = "";
> > >   int level = -1, ind = -1;
> > >
> > > try {
> > >                 Connection conn = null;
> > >
> > Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
> > >
> > >
> >
> conn=DriverManager.getConnection("jdbc:odbc:driver={Microsoft
> > > Access Driver
> > > (*.mdb)};DBQ=C:/tomcat/webapps/db1/db1.mdb");
> > >                 Statement stmt =
> > > conn.createStatement();
> > >
> > >                 String query = "SELECT * FROM user
> > > where name = '" + userid + "'";
> > >
> > >                 ResultSet st =
> > > stmt.executeQuery(query);
> > >                 if (st.next()) {
> > >                     pwd =
> > st.getString("password");
> > >
> > >                                         level =
> > st.getInt("level");
> > >                     System.err.println("Query
> > > result="+userid+"/"+pwd+"/"+level);
> > >                 }
> > >                                 else {
> > >                                         ind = -2;
> > >
> > System.out.println("No user with name " + userid
> > > + " available in the database");
> > >                                 }
> > >
> > >                 if (stmt != null) {
> > >                     stmt.close();
> > >                 }
> > >
> > >                 if (conn != null) {
> > >                     conn.close();
> > >                 }
> > >
> > >             } catch (Exception e) {
> > >                 e.printStackTrace();
> > >             }
> > >                 if(pwd.equals(passwd)) {
> > >                                         ind =
> > level;
> > >                                 }
> > >                 // else ind = -1;
> > >
> > >
> > System.out.println("Ind - > " + ind);
> > > %>
> > >
> > > <script language="JavaScript"
> > type="text/JavaScript">
> > > var ind = <%= ind %>
> > >
> > > function loadHtml() {
> > >         //alert("in loadHtml()");
> > >         if(ind == -2) {
> > >                 alert("Not a valid user");
> > >                 location.href = "login.jsp";
> > >                 return;
> > >         }
> > >         if (ind == -1) {
> > >                 alert("Incorrect password");
> > >                 location.href = "login.jsp";
> > >                 return;
> > >         }
> > >         else {
> > >                 //alert("Correct password");
> > >                 location.href =
> > "Second_Page.html";
> > >                 return;
> > >         }
> > > }
> > >
> > > </script>
> > >  </head>
> > >
> > >  <body onload="javascript:loadHtml()">
> > >
> > > <!-- User Name : <%= userid %><br>
> > >  Password  : <%= passwd %> -->
> > >
> > >  </body>
> > >
> > >  </html>
> > > --- code ends here ---
> > >
> > > It works. But is it the right way to do? Pls
> > advice.
> > >
> > > --- Antony Paul <an...@gmail.com> wrote:
> > >
> > > > By default server.xml contains have a
> > > > <GlobalNamingResources>. You
> > > > have to add your resources in there.
> > > >
> > > > rgds
> > > > Antony Paul
> > > >
> > > >
> > > > On Mon, 21 Feb 2005 19:56:23 -0800 (PST), U K
> > Laxmi
> > > > <la...@yahoo.com> wrote:
> > > > > As just moved the GlobalNamingResources inside
> > the
> > > > > main <server> in my server.xml residing in
> > > > > TOMCAT_HOME/conf directory. When i restart
> > tomcat
> > > > > 5.5.7 it's throwing up following exception.
> > > > > INFO: Starting Servlet Engine: Apache
> > Tomcat/5.5.7
> > > > > Feb 22, 2005 11:51:46 AM
> > > > > org.apache.catalina.realm.UserDatabaseRealm
> > start
> > > > > SEVERE: Exception looking up UserDatabase
> > under
> > > > key
> > > > > UserDatabase
> > > > > javax.naming.NameNotFoundException: Name
> > > > UserDatabase
> > > > > is not bound in this Conte
> > > > > xt
> > > > >         at
> > > > >
> > > >
> > >
> >
> org.apache.naming.NamingContext.lookup(NamingContext.java:769)
> > > > >         at
> > > > >
> > > >
> > >
> >
> org.apache.naming.NamingContext.lookup(NamingContext.java:152)
> > > > >         at
> > > > >
> > > >
> > >
> >
> org.apache.catalina.realm.UserDatabaseRealm.start(UserDatabaseRealm.j
> > > > > ava:222)
> > > > >         at
> > > > >
> > > >
> > >
> >
> org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1003)
> > > > >
> >
> === message truncated ===
> 
> __________________________________
> Do you Yahoo!?
> Meet the all-new My Yahoo! - Try it today!
> http://my.yahoo.com
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Name jdbc is not bound in this Context error

Posted by U K Laxmi <la...@yahoo.com>.
Yes i read and did as per the document. When it didn't
work, i followed the suggetions given to many users in
the mailing lists in the internet and now i guess i
messed up. Actually in the error, it says, no suitable
driver found. 

I'm using Ms Access as it's free. Do we have any free
driver available in the form of jar to use in place of
JDBC-ODBC bridge driver? Or it's not required if
configuration is correct. Pls let me know. I've pasted
all relevant code in my first mail itself. If time
permits, any of you can try & give me the solution.
It'll be a great help.

I've integrated tomcat 5.5.7 with apache 2. Does this
has any impact on the above.

--- Antony Paul <an...@gmail.com> wrote:

> If you followed the tomcat docs you will have no
> problem in DBCP
> getting to work. Going for Globalnamingresources is
> needed if you need
> to access it will all applications. Try to configure
> it as per the doc
> in following URL.
> 
>
http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples-howto.html
> 
> follow MySQL config. And no need to put commons*.jar
> in commons/lib as
> TC by default comes with it.
> 
> rgds
> Antony Paul
> 
> 
> On Mon, 21 Feb 2005 21:52:13 -0800 (PST), U K Laxmi
> <la...@yahoo.com> wrote:
> > I tried without GlobalNamingResources. No luck.
> When
> > googled, i found that if we include
> > GlobalNamingResource tag, then it will be
> available in
> > all web context.
> > 
> > After spending enough time on that, now i coded
> all
> > database related stuff in JSP in the way we do in
> > stand alone application. I mean -
> > 
> > Coding like this in jspo itself.
> > 
> > ---- code --
> > <%@ page contentType="text/html"
> import="java.sql.*"%>
> > 
> >  <html>
> > 
> >  <head><title>simmPlan - simple material planning
> > system</title>
> > <script language="JavaScript"
> > src="/js/default.js"></script>
> > 
> >  <%
> > 
> >   String userid = request.getParameter("userid");
> >   String passwd = request.getParameter("passwd");
> >   System.out.println("Password: " + passwd);
> >   String pwd = "", str = "";
> >   int level = -1, ind = -1;
> > 
> > try {
> >                 Connection conn = null;
> >                                
> Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
> > 
> >
>
conn=DriverManager.getConnection("jdbc:odbc:driver={Microsoft
> > Access Driver
> > (*.mdb)};DBQ=C:/tomcat/webapps/db1/db1.mdb");
> >                 Statement stmt =
> > conn.createStatement();
> > 
> >                 String query = "SELECT * FROM user
> > where name = '" + userid + "'";
> > 
> >                 ResultSet st =
> > stmt.executeQuery(query);
> >                 if (st.next()) {
> >                     pwd =
> st.getString("password");
> > 
> >                                         level =
> st.getInt("level");
> >                     System.err.println("Query
> > result="+userid+"/"+pwd+"/"+level);
> >                 }
> >                                 else {
> >                                         ind = -2;
> >                                        
> System.out.println("No user with name " + userid
> > + " available in the database");
> >                                 }
> > 
> >                 if (stmt != null) {
> >                     stmt.close();
> >                 }
> > 
> >                 if (conn != null) {
> >                     conn.close();
> >                 }
> > 
> >             } catch (Exception e) {
> >                 e.printStackTrace();
> >             }
> >                 if(pwd.equals(passwd)) {
> >                                         ind =
> level;
> >                                 }
> >                 // else ind = -1;
> > 
> >                                 
> System.out.println("Ind - > " + ind);
> > %>
> > 
> > <script language="JavaScript"
> type="text/JavaScript">
> > var ind = <%= ind %>
> > 
> > function loadHtml() {
> >         //alert("in loadHtml()");
> >         if(ind == -2) {
> >                 alert("Not a valid user");
> >                 location.href = "login.jsp";
> >                 return;
> >         }
> >         if (ind == -1) {
> >                 alert("Incorrect password");
> >                 location.href = "login.jsp";
> >                 return;
> >         }
> >         else {
> >                 //alert("Correct password");
> >                 location.href =
> "Second_Page.html";
> >                 return;
> >         }
> > }
> > 
> > </script>
> >  </head>
> > 
> >  <body onload="javascript:loadHtml()">
> > 
> > <!-- User Name : <%= userid %><br>
> >  Password  : <%= passwd %> -->
> > 
> >  </body>
> > 
> >  </html>
> > --- code ends here ---
> > 
> > It works. But is it the right way to do? Pls
> advice.
> > 
> > --- Antony Paul <an...@gmail.com> wrote:
> > 
> > > By default server.xml contains have a
> > > <GlobalNamingResources>. You
> > > have to add your resources in there.
> > >
> > > rgds
> > > Antony Paul
> > >
> > >
> > > On Mon, 21 Feb 2005 19:56:23 -0800 (PST), U K
> Laxmi
> > > <la...@yahoo.com> wrote:
> > > > As just moved the GlobalNamingResources inside
> the
> > > > main <server> in my server.xml residing in
> > > > TOMCAT_HOME/conf directory. When i restart
> tomcat
> > > > 5.5.7 it's throwing up following exception.
> > > > INFO: Starting Servlet Engine: Apache
> Tomcat/5.5.7
> > > > Feb 22, 2005 11:51:46 AM
> > > > org.apache.catalina.realm.UserDatabaseRealm
> start
> > > > SEVERE: Exception looking up UserDatabase
> under
> > > key
> > > > UserDatabase
> > > > javax.naming.NameNotFoundException: Name
> > > UserDatabase
> > > > is not bound in this Conte
> > > > xt
> > > >         at
> > > >
> > >
> >
>
org.apache.naming.NamingContext.lookup(NamingContext.java:769)
> > > >         at
> > > >
> > >
> >
>
org.apache.naming.NamingContext.lookup(NamingContext.java:152)
> > > >         at
> > > >
> > >
> >
>
org.apache.catalina.realm.UserDatabaseRealm.start(UserDatabaseRealm.j
> > > > ava:222)
> > > >         at
> > > >
> > >
> >
>
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1003)
> > > >
> 
=== message truncated ===



		
__________________________________ 
Do you Yahoo!? 
Meet the all-new My Yahoo! - Try it today! 
http://my.yahoo.com 
 


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Name jdbc is not bound in this Context error

Posted by Antony Paul <an...@gmail.com>.
If you followed the tomcat docs you will have no problem in DBCP
getting to work. Going for Globalnamingresources is needed if you need
to access it will all applications. Try to configure it as per the doc
in following URL.

http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples-howto.html

follow MySQL config. And no need to put commons*.jar in commons/lib as
TC by default comes with it.

rgds
Antony Paul


On Mon, 21 Feb 2005 21:52:13 -0800 (PST), U K Laxmi <la...@yahoo.com> wrote:
> I tried without GlobalNamingResources. No luck. When
> googled, i found that if we include
> GlobalNamingResource tag, then it will be available in
> all web context.
> 
> After spending enough time on that, now i coded all
> database related stuff in JSP in the way we do in
> stand alone application. I mean -
> 
> Coding like this in jspo itself.
> 
> ---- code --
> <%@ page contentType="text/html" import="java.sql.*"%>
> 
>  <html>
> 
>  <head><title>simmPlan - simple material planning
> system</title>
> <script language="JavaScript"
> src="/js/default.js"></script>
> 
>  <%
> 
>   String userid = request.getParameter("userid");
>   String passwd = request.getParameter("passwd");
>   System.out.println("Password: " + passwd);
>   String pwd = "", str = "";
>   int level = -1, ind = -1;
> 
> try {
>                 Connection conn = null;
>                                 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
> 
> conn=DriverManager.getConnection("jdbc:odbc:driver={Microsoft
> Access Driver
> (*.mdb)};DBQ=C:/tomcat/webapps/db1/db1.mdb");
>                 Statement stmt =
> conn.createStatement();
> 
>                 String query = "SELECT * FROM user
> where name = '" + userid + "'";
> 
>                 ResultSet st =
> stmt.executeQuery(query);
>                 if (st.next()) {
>                     pwd = st.getString("password");
> 
>                                         level = st.getInt("level");
>                     System.err.println("Query
> result="+userid+"/"+pwd+"/"+level);
>                 }
>                                 else {
>                                         ind = -2;
>                                         System.out.println("No user with name " + userid
> + " available in the database");
>                                 }
> 
>                 if (stmt != null) {
>                     stmt.close();
>                 }
> 
>                 if (conn != null) {
>                     conn.close();
>                 }
> 
>             } catch (Exception e) {
>                 e.printStackTrace();
>             }
>                 if(pwd.equals(passwd)) {
>                                         ind = level;
>                                 }
>                 // else ind = -1;
> 
>                                  System.out.println("Ind - > " + ind);
> %>
> 
> <script language="JavaScript" type="text/JavaScript">
> var ind = <%= ind %>
> 
> function loadHtml() {
>         //alert("in loadHtml()");
>         if(ind == -2) {
>                 alert("Not a valid user");
>                 location.href = "login.jsp";
>                 return;
>         }
>         if (ind == -1) {
>                 alert("Incorrect password");
>                 location.href = "login.jsp";
>                 return;
>         }
>         else {
>                 //alert("Correct password");
>                 location.href = "Second_Page.html";
>                 return;
>         }
> }
> 
> </script>
>  </head>
> 
>  <body onload="javascript:loadHtml()">
> 
> <!-- User Name : <%= userid %><br>
>  Password  : <%= passwd %> -->
> 
>  </body>
> 
>  </html>
> --- code ends here ---
> 
> It works. But is it the right way to do? Pls advice.
> 
> --- Antony Paul <an...@gmail.com> wrote:
> 
> > By default server.xml contains have a
> > <GlobalNamingResources>. You
> > have to add your resources in there.
> >
> > rgds
> > Antony Paul
> >
> >
> > On Mon, 21 Feb 2005 19:56:23 -0800 (PST), U K Laxmi
> > <la...@yahoo.com> wrote:
> > > As just moved the GlobalNamingResources inside the
> > > main <server> in my server.xml residing in
> > > TOMCAT_HOME/conf directory. When i restart tomcat
> > > 5.5.7 it's throwing up following exception.
> > > INFO: Starting Servlet Engine: Apache Tomcat/5.5.7
> > > Feb 22, 2005 11:51:46 AM
> > > org.apache.catalina.realm.UserDatabaseRealm start
> > > SEVERE: Exception looking up UserDatabase under
> > key
> > > UserDatabase
> > > javax.naming.NameNotFoundException: Name
> > UserDatabase
> > > is not bound in this Conte
> > > xt
> > >         at
> > >
> >
> org.apache.naming.NamingContext.lookup(NamingContext.java:769)
> > >         at
> > >
> >
> org.apache.naming.NamingContext.lookup(NamingContext.java:152)
> > >         at
> > >
> >
> org.apache.catalina.realm.UserDatabaseRealm.start(UserDatabaseRealm.j
> > > ava:222)
> > >         at
> > >
> >
> org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1003)
> > >
> > >         at
> > >
> >
> org.apache.catalina.core.StandardEngine.start(StandardEngine.java:440
> > > )
> > >         at
> > >
> >
> org.apache.catalina.core.StandardService.start(StandardService.java:4
> > > 50)
> > >         at
> > >
> >
> org.apache.catalina.core.StandardServer.start(StandardServer.java:683
> > > )
> > >         at
> > >
> >
> org.apache.catalina.startup.Catalina.start(Catalina.java:537)
> > >         at
> > >
> > sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> > > Method)
> > >         at
> > >
> > sun.reflect.NativeMethodAccessorImpl.invoke(Unknown
> > > Source)
> > >         at
> > >
> >
> sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
> > > Source)
> > >         at java.lang.reflect.Method.invoke(Unknown
> > > Source)
> > >         at
> > >
> >
> org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271)
> > >         at
> > >
> >
> org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409)
> > > Feb 22, 2005 11:51:46 AM
> > > org.apache.catalina.startup.Catalina start
> > > SEVERE: Catalina.start:
> > > LifecycleException:  No UserDatabase component
> > found
> > > under key UserDatabase
> > >         at
> > >
> >
> org.apache.catalina.realm.UserDatabaseRealm.start(UserDatabaseRealm.j
> > > ava:228)
> > >         at
> > >
> >
> org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1003)
> > >
> > >         at
> > >
> >
> org.apache.catalina.core.StandardEngine.start(StandardEngine.java:440
> > > )
> > >         at
> > >
> >
> org.apache.catalina.core.StandardService.start(StandardService.java:4
> > > 50)
> > >         at
> > >
> >
> org.apache.catalina.core.StandardServer.start(StandardServer.java:683
> > > )
> > >         at
> > >
> >
> org.apache.catalina.startup.Catalina.start(Catalina.java:537)
> > >         at
> > >
> > sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> > > Method)
> > >         at
> > >
> > sun.reflect.NativeMethodAccessorImpl.invoke(Unknown
> > > Source)
> > >         at
> > >
> >
> sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
> > > Source)
> > >         at java.lang.reflect.Method.invoke(Unknown
> > > Source)
> > >         at
> > >
> >
> org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271)
> > >         at
> > >
> >
> org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409)
> > > Feb 22, 2005 11:51:46 AM
> > > org.apache.catalina.startup.Catalina start
> > > INFO: Server startup in 391 ms
> > >
> > > Pls help to fix the problem.
> > >
> > > Thanks,
> > > Laxmi
> > >
> > > --- Antony Paul <an...@gmail.com> wrote:
> > >
> > > > It seems you still have problem. You can google
> > for
> > > > the answer. One
> > > > thing I know is GlobalNamingResources should
> > come
> > > > inside the Server
> > > > element and not inside Context element.
> > > >
> > > > rgds
> > > > Antony Paul
> > > >
> > > >
> > > > On Fri, 18 Feb 2005 22:47:06 -0800 (PST), U K
> > Laxmi
> > > > <la...@yahoo.com> wrote:
> > > > > I could able to get thro' JarperException.
> > Thanks
> > > > for
> > > > > replies.
> > > > >
> > > > > Now facing new problem.
> > > > >
> > > > > I'm getting "NameNotFoundException" -  Name
> > jdbc
> > > > is
> > > > > not bound in this Context
> > > > >
> > > > > Environment what i'm using is: Apache 2,
> > Tomcat
> > > > 5.5,
> > > > > Netscape 7.2, MsAccess 2003 on windows 2000
> > > > machine.
> > > > >
> > > > > I integrated tomcat and apache as apache
> > doesn't
> > > > > support jsps. I wrote a JSP called test-db.jsp
> > > > which
> > > > > in turn calls java program TestSQLLoad.java.
> > This
> > > > > TestSQLLoad.java performs dattabase operation,
> > > > fetches
> > > > > the data from table and that data is displayed
> > on
> > > > > Netscape thro' jsp.
> > > > >
> > > > > 1. test-db.jsp resides ina directory
> > > > > TOMCAT_HOME/webapps/web/JSP. Contents are as
> > > > follows:
> > > > >
> > > > > <%@ page contentType="text/html"
> > > > > import="testpkg.TestSQLLoad"%>
> > > > >
> > > > >         <html>
> > > > >       <head>
> > > > >         <title>DB Test</title>
> > > > >       </head>
> > > > >       <body>
> > > > >
> > > > >       <%
> > > > >         TestSQLLoad tst = new TestSQLLoad();
> > > > >         tst.init();
> > > > >       %>
> > > > >
> > > > >       <h2>Results</h2>
> > > > >         User -> <%= tst.getUser() %><br/>
> > > > >         Pwd -> <%= tst.getPassword() %><br/>
> > > > >         Id -> <%= tst.getID() %>
> > > > >
> >
> === message truncated ===
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail - You care about security. So do we.
> http://promotions.yahoo.com/new_mail
>

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Name jdbc is not bound in this Context error

Posted by U K Laxmi <la...@yahoo.com>.
Sure to do the changes you mentioned. Pls do send the
config file for connection pooling and also guidelines
for how to use it in my program. It will be a great
help.

I'm developing web based application for using it
inhouse. Later part of time, it may grow to a big MRP
application based on the requirement of the company.
If i go ahead with this kind of structure (the one i
sent in my previous mail), does it cause any rpoblems?
Pls advice.

--- Robert F Hall <rf...@berkeley.edu> wrote:

> U K,
> 
> "It works" as you said, but there are a couple of
> things I'll recommend:
> 
> First, you should move your Connection, ResultSet
> and Statement 
> declarations before
> the try {} block and add a finally {} block where
> you check for null 
> values and close
> the resources if not null.
> 
>     Connection conn = null;
>      Statement stmt = null;
>      ResultSet res = null;
>       try {
>             ......
>        }
>        catch {
>              ....
>         }
>         finally {
>              if (stmt != null ) {
>                  try {
>                      stmnt.close();
>                  }
>                   catch (SQLException se) {
>                       log.error(se.getMessage);
>                  }
>               }
>               ....
>     
> Second, you should use a connection pool.  I don't
> have a Tomcat config 
> readily
> available.   But can follow up with one if you need
> it.
> 
> -Robert
> 
> U K Laxmi wrote:
> 
> >I tried without GlobalNamingResources. No luck.
> When
> >googled, i found that if we include
> >GlobalNamingResource tag, then it will be available
> in
> >all web context. 
> >
> >After spending enough time on that, now i coded all
> >database related stuff in JSP in the way we do in
> >stand alone application. I mean - 
> >
> >Coding like this in jspo itself.
> >
> >---- code --
> ><%@ page contentType="text/html"
> import="java.sql.*"%>
> >
> > <html>
> >
> > <head><title>simmPlan - simple material planning
> >system</title>
> ><script language="JavaScript"
> >src="/js/default.js"></script>
> >
> > <%
> >
> >  String userid = request.getParameter("userid");
> >  String passwd = request.getParameter("passwd");
> >  System.out.println("Password: " + passwd);
> >  String pwd = "", str = "";
> >  int level = -1, ind = -1;
> >
> >try {
> >                Connection conn = null;
> >				Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
> >			
>
>conn=DriverManager.getConnection("jdbc:odbc:driver={Microsoft
> >Access Driver
> >(*.mdb)};DBQ=C:/tomcat/webapps/db1/db1.mdb");
> >                Statement stmt =
> >conn.createStatement();
> >                        
> >                String query = "SELECT * FROM user
> >where name = '" + userid + "'";
> >                
> >                ResultSet st =
> >stmt.executeQuery(query);
> >                if (st.next()) {                   
> 
> >                    pwd = st.getString("password");
>   
> >                
> >					level = st.getInt("level");
> >                    System.err.println("Query
> >result="+userid+"/"+pwd+"/"+level);
> >                }
> >				else {
> >					ind = -2;
> >					System.out.println("No user with name " +
> userid
> >+ " available in the database");
> >				}
> >
> >                if (stmt != null) {
> >                    stmt.close();
> >                }
> >
> >                if (conn != null) {
> >                    conn.close();
> >                }
> >				 
> >            } catch (Exception e) {
> >                e.printStackTrace();
> >            }   
> >		if(pwd.equals(passwd)) {
> >					ind = level;
> >				}
> >                // else ind = -1;
> >
> >				 System.out.println("Ind - > " + ind);
> >%>
> >
> ><script language="JavaScript"
> type="text/JavaScript">
> >var ind = <%= ind %>
> >
> >function loadHtml() {
> >	//alert("in loadHtml()");
> >	if(ind == -2) {
> >		alert("Not a valid user");
> >		location.href = "login.jsp";
> >		return;
> >	}
> >	if (ind == -1) {
> >		alert("Incorrect password");
> >		location.href = "login.jsp";
> >		return;
> >	}
> >	else {
> >		//alert("Correct password");
> >		location.href = "Second_Page.html";
> >		return;
> >	}
> >}
> >
> >
> ></script>
> > </head>
> >
> > <body onload="javascript:loadHtml()">
> >
> ><!-- User Name : <%= userid %><br>
> > Password  : <%= passwd %> -->
> >
> > </body>
> >
> > </html>
> >--- code ends here ---
> >
> >It works. But is it the right way to do? Pls
> advice.
> >
> >--- Antony Paul <an...@gmail.com> wrote:
> >
> >  
> >
> >>By default server.xml contains have a 
> >><GlobalNamingResources>. You
> >>have to add your resources in there.
> >>
> >>rgds
> >>Antony Paul
> >>
> >>
> >>On Mon, 21 Feb 2005 19:56:23 -0800 (PST), U K
> Laxmi
> >><la...@yahoo.com> wrote:
> >>    
> >>
> >>>As just moved the GlobalNamingResources inside
> the
> >>>main <server> in my server.xml residing in
> >>>TOMCAT_HOME/conf directory. When i restart tomcat
> >>>5.5.7 it's throwing up following exception.
> >>>INFO: Starting Servlet Engine: Apache
> Tomcat/5.5.7
> >>>Feb 22, 2005 11:51:46 AM
> >>>org.apache.catalina.realm.UserDatabaseRealm start
> >>>SEVERE: Exception looking up UserDatabase under
> >>>      
> >>>
> >>key
> >>    
> >>
> >>>UserDatabase
> >>>javax.naming.NameNotFoundException: Name
> >>>      
> >>>
> 
=== message truncated ===



		
__________________________________ 
Do you Yahoo!? 
Read only the mail you want - Yahoo! Mail SpamGuard. 
http://promotions.yahoo.com/new_mail 

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Name jdbc is not bound in this Context error

Posted by Robert F Hall <rf...@berkeley.edu>.
U K,

"It works" as you said, but there are a couple of things I'll recommend:

First, you should move your Connection, ResultSet and Statement 
declarations before
the try {} block and add a finally {} block where you check for null 
values and close
the resources if not null.

    Connection conn = null;
     Statement stmt = null;
     ResultSet res = null;
      try {
            ......
       }
       catch {
             ....
        }
        finally {
             if (stmt != null ) {
                 try {
                     stmnt.close();
                 }
                  catch (SQLException se) {
                      log.error(se.getMessage);
                 }
              }
              ....
    
Second, you should use a connection pool.  I don't have a Tomcat config 
readily
available.   But can follow up with one if you need it.

-Robert

U K Laxmi wrote:

>I tried without GlobalNamingResources. No luck. When
>googled, i found that if we include
>GlobalNamingResource tag, then it will be available in
>all web context. 
>
>After spending enough time on that, now i coded all
>database related stuff in JSP in the way we do in
>stand alone application. I mean - 
>
>Coding like this in jspo itself.
>
>---- code --
><%@ page contentType="text/html" import="java.sql.*"%>
>
> <html>
>
> <head><title>simmPlan - simple material planning
>system</title>
><script language="JavaScript"
>src="/js/default.js"></script>
>
> <%
>
>  String userid = request.getParameter("userid");
>  String passwd = request.getParameter("passwd");
>  System.out.println("Password: " + passwd);
>  String pwd = "", str = "";
>  int level = -1, ind = -1;
>
>try {
>                Connection conn = null;
>				Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
>			
>conn=DriverManager.getConnection("jdbc:odbc:driver={Microsoft
>Access Driver
>(*.mdb)};DBQ=C:/tomcat/webapps/db1/db1.mdb");
>                Statement stmt =
>conn.createStatement();
>                        
>                String query = "SELECT * FROM user
>where name = '" + userid + "'";
>                
>                ResultSet st =
>stmt.executeQuery(query);
>                if (st.next()) {                    
>                    pwd = st.getString("password");   
>                
>					level = st.getInt("level");
>                    System.err.println("Query
>result="+userid+"/"+pwd+"/"+level);
>                }
>				else {
>					ind = -2;
>					System.out.println("No user with name " + userid
>+ " available in the database");
>				}
>
>                if (stmt != null) {
>                    stmt.close();
>                }
>
>                if (conn != null) {
>                    conn.close();
>                }
>				 
>            } catch (Exception e) {
>                e.printStackTrace();
>            }   
>		if(pwd.equals(passwd)) {
>					ind = level;
>				}
>                // else ind = -1;
>
>				 System.out.println("Ind - > " + ind);
>%>
>
><script language="JavaScript" type="text/JavaScript">
>var ind = <%= ind %>
>
>function loadHtml() {
>	//alert("in loadHtml()");
>	if(ind == -2) {
>		alert("Not a valid user");
>		location.href = "login.jsp";
>		return;
>	}
>	if (ind == -1) {
>		alert("Incorrect password");
>		location.href = "login.jsp";
>		return;
>	}
>	else {
>		//alert("Correct password");
>		location.href = "Second_Page.html";
>		return;
>	}
>}
>
>
></script>
> </head>
>
> <body onload="javascript:loadHtml()">
>
><!-- User Name : <%= userid %><br>
> Password  : <%= passwd %> -->
>
> </body>
>
> </html>
>--- code ends here ---
>
>It works. But is it the right way to do? Pls advice.
>
>--- Antony Paul <an...@gmail.com> wrote:
>
>  
>
>>By default server.xml contains have a 
>><GlobalNamingResources>. You
>>have to add your resources in there.
>>
>>rgds
>>Antony Paul
>>
>>
>>On Mon, 21 Feb 2005 19:56:23 -0800 (PST), U K Laxmi
>><la...@yahoo.com> wrote:
>>    
>>
>>>As just moved the GlobalNamingResources inside the
>>>main <server> in my server.xml residing in
>>>TOMCAT_HOME/conf directory. When i restart tomcat
>>>5.5.7 it's throwing up following exception.
>>>INFO: Starting Servlet Engine: Apache Tomcat/5.5.7
>>>Feb 22, 2005 11:51:46 AM
>>>org.apache.catalina.realm.UserDatabaseRealm start
>>>SEVERE: Exception looking up UserDatabase under
>>>      
>>>
>>key
>>    
>>
>>>UserDatabase
>>>javax.naming.NameNotFoundException: Name
>>>      
>>>
>>UserDatabase
>>    
>>
>>>is not bound in this Conte
>>>xt
>>>        at
>>>
>>>      
>>>
>org.apache.naming.NamingContext.lookup(NamingContext.java:769)
>  
>
>>>        at
>>>
>>>      
>>>
>org.apache.naming.NamingContext.lookup(NamingContext.java:152)
>  
>
>>>        at
>>>
>>>      
>>>
>org.apache.catalina.realm.UserDatabaseRealm.start(UserDatabaseRealm.j
>  
>
>>>ava:222)
>>>        at
>>>
>>>      
>>>
>org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1003)
>  
>
>>>        at
>>>
>>>      
>>>
>org.apache.catalina.core.StandardEngine.start(StandardEngine.java:440
>  
>
>>>)
>>>        at
>>>
>>>      
>>>
>org.apache.catalina.core.StandardService.start(StandardService.java:4
>  
>
>>>50)
>>>        at
>>>
>>>      
>>>
>org.apache.catalina.core.StandardServer.start(StandardServer.java:683
>  
>
>>>)
>>>        at
>>>
>>>      
>>>
>org.apache.catalina.startup.Catalina.start(Catalina.java:537)
>  
>
>>>        at
>>>
>>>      
>>>
>>sun.reflect.NativeMethodAccessorImpl.invoke0(Native
>>    
>>
>>>Method)
>>>        at
>>>
>>>      
>>>
>>sun.reflect.NativeMethodAccessorImpl.invoke(Unknown
>>    
>>
>>>Source)
>>>        at
>>>
>>>      
>>>
>sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
>  
>
>>>Source)
>>>        at java.lang.reflect.Method.invoke(Unknown
>>>Source)
>>>        at
>>>
>>>      
>>>
>org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271)
>  
>
>>>        at
>>>
>>>      
>>>
>org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409)
>  
>
>>>Feb 22, 2005 11:51:46 AM
>>>org.apache.catalina.startup.Catalina start
>>>SEVERE: Catalina.start:
>>>LifecycleException:  No UserDatabase component
>>>      
>>>
>>found
>>    
>>
>>>under key UserDatabase
>>>        at
>>>
>>>      
>>>
>org.apache.catalina.realm.UserDatabaseRealm.start(UserDatabaseRealm.j
>  
>
>>>ava:228)
>>>        at
>>>
>>>      
>>>
>org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1003)
>  
>
>>>        at
>>>
>>>      
>>>
>org.apache.catalina.core.StandardEngine.start(StandardEngine.java:440
>  
>
>>>)
>>>        at
>>>
>>>      
>>>
>org.apache.catalina.core.StandardService.start(StandardService.java:4
>  
>
>>>50)
>>>        at
>>>
>>>      
>>>
>org.apache.catalina.core.StandardServer.start(StandardServer.java:683
>  
>
>>>)
>>>        at
>>>
>>>      
>>>
>org.apache.catalina.startup.Catalina.start(Catalina.java:537)
>  
>
>>>        at
>>>
>>>      
>>>
>>sun.reflect.NativeMethodAccessorImpl.invoke0(Native
>>    
>>
>>>Method)
>>>        at
>>>
>>>      
>>>
>>sun.reflect.NativeMethodAccessorImpl.invoke(Unknown
>>    
>>
>>>Source)
>>>        at
>>>
>>>      
>>>
>sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
>  
>
>>>Source)
>>>        at java.lang.reflect.Method.invoke(Unknown
>>>Source)
>>>        at
>>>
>>>      
>>>
>org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271)
>  
>
>>>        at
>>>
>>>      
>>>
>org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409)
>  
>
>>>Feb 22, 2005 11:51:46 AM
>>>org.apache.catalina.startup.Catalina start
>>>INFO: Server startup in 391 ms
>>>
>>>Pls help to fix the problem.
>>>
>>>Thanks,
>>>Laxmi
>>>
>>>--- Antony Paul <an...@gmail.com> wrote:
>>>
>>>      
>>>
>>>>It seems you still have problem. You can google
>>>>        
>>>>
>>for
>>    
>>
>>>>the answer. One
>>>>thing I know is GlobalNamingResources should
>>>>        
>>>>
>>come
>>    
>>
>>>>inside the Server
>>>>element and not inside Context element.
>>>>
>>>>rgds
>>>>Antony Paul
>>>>
>>>>
>>>>On Fri, 18 Feb 2005 22:47:06 -0800 (PST), U K
>>>>        
>>>>
>>Laxmi
>>    
>>
>>>><la...@yahoo.com> wrote:
>>>>        
>>>>
>>>>>I could able to get thro' JarperException.
>>>>>          
>>>>>
>>Thanks
>>    
>>
>>>>for
>>>>        
>>>>
>>>>>replies.
>>>>>
>>>>>Now facing new problem.
>>>>>
>>>>>I'm getting "NameNotFoundException" -  Name
>>>>>          
>>>>>
>>jdbc
>>    
>>
>>>>is
>>>>        
>>>>
>>>>>not bound in this Context
>>>>>
>>>>>Environment what i'm using is: Apache 2,
>>>>>          
>>>>>
>>Tomcat
>>    
>>
>>>>5.5,
>>>>        
>>>>
>>>>>Netscape 7.2, MsAccess 2003 on windows 2000
>>>>>          
>>>>>
>>>>machine.
>>>>        
>>>>
>>>>>I integrated tomcat and apache as apache
>>>>>          
>>>>>
>>doesn't
>>    
>>
>>>>>support jsps. I wrote a JSP called test-db.jsp
>>>>>          
>>>>>
>>>>which
>>>>        
>>>>
>>>>>in turn calls java program TestSQLLoad.java.
>>>>>          
>>>>>
>>This
>>    
>>
>>>>>TestSQLLoad.java performs dattabase operation,
>>>>>          
>>>>>
>>>>fetches
>>>>        
>>>>
>>>>>the data from table and that data is displayed
>>>>>          
>>>>>
>>on
>>    
>>
>>>>>Netscape thro' jsp.
>>>>>
>>>>>1. test-db.jsp resides ina directory
>>>>>TOMCAT_HOME/webapps/web/JSP. Contents are as
>>>>>          
>>>>>
>>>>follows:
>>>>        
>>>>
>>>>><%@ page contentType="text/html"
>>>>>import="testpkg.TestSQLLoad"%>
>>>>>
>>>>>        <html>
>>>>>      <head>
>>>>>        <title>DB Test</title>
>>>>>      </head>
>>>>>      <body>
>>>>>
>>>>>      <%
>>>>>        TestSQLLoad tst = new TestSQLLoad();
>>>>>        tst.init();
>>>>>      %>
>>>>>
>>>>>      <h2>Results</h2>
>>>>>        User -> <%= tst.getUser() %><br/>
>>>>>        Pwd -> <%= tst.getPassword() %><br/>
>>>>>        Id -> <%= tst.getID() %>
>>>>>
>>>>>          
>>>>>
>=== message truncated ===
>
>
>
>	
>		
>__________________________________ 
>Do you Yahoo!? 
>Yahoo! Mail - You care about security. So do we. 
>http://promotions.yahoo.com/new_mail
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
>  
>


Re: Name jdbc is not bound in this Context error

Posted by U K Laxmi <la...@yahoo.com>.
I tried without GlobalNamingResources. No luck. When
googled, i found that if we include
GlobalNamingResource tag, then it will be available in
all web context. 

After spending enough time on that, now i coded all
database related stuff in JSP in the way we do in
stand alone application. I mean - 

Coding like this in jspo itself.

---- code --
<%@ page contentType="text/html" import="java.sql.*"%>

 <html>

 <head><title>simmPlan - simple material planning
system</title>
<script language="JavaScript"
src="/js/default.js"></script>

 <%

  String userid = request.getParameter("userid");
  String passwd = request.getParameter("passwd");
  System.out.println("Password: " + passwd);
  String pwd = "", str = "";
  int level = -1, ind = -1;

try {
                Connection conn = null;
				Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
			
conn=DriverManager.getConnection("jdbc:odbc:driver={Microsoft
Access Driver
(*.mdb)};DBQ=C:/tomcat/webapps/db1/db1.mdb");
                Statement stmt =
conn.createStatement();
                        
                String query = "SELECT * FROM user
where name = '" + userid + "'";
                
                ResultSet st =
stmt.executeQuery(query);
                if (st.next()) {                    
                    pwd = st.getString("password");   
                
					level = st.getInt("level");
                    System.err.println("Query
result="+userid+"/"+pwd+"/"+level);
                }
				else {
					ind = -2;
					System.out.println("No user with name " + userid
+ " available in the database");
				}

                if (stmt != null) {
                    stmt.close();
                }

                if (conn != null) {
                    conn.close();
                }
				 
            } catch (Exception e) {
                e.printStackTrace();
            }   
		if(pwd.equals(passwd)) {
					ind = level;
				}
                // else ind = -1;

				 System.out.println("Ind - > " + ind);
%>

<script language="JavaScript" type="text/JavaScript">
var ind = <%= ind %>

function loadHtml() {
	//alert("in loadHtml()");
	if(ind == -2) {
		alert("Not a valid user");
		location.href = "login.jsp";
		return;
	}
	if (ind == -1) {
		alert("Incorrect password");
		location.href = "login.jsp";
		return;
	}
	else {
		//alert("Correct password");
		location.href = "Second_Page.html";
		return;
	}
}


</script>
 </head>

 <body onload="javascript:loadHtml()">

<!-- User Name : <%= userid %><br>
 Password  : <%= passwd %> -->

 </body>

 </html>
--- code ends here ---

It works. But is it the right way to do? Pls advice.

--- Antony Paul <an...@gmail.com> wrote:

> By default server.xml contains have a 
> <GlobalNamingResources>. You
> have to add your resources in there.
> 
> rgds
> Antony Paul
> 
> 
> On Mon, 21 Feb 2005 19:56:23 -0800 (PST), U K Laxmi
> <la...@yahoo.com> wrote:
> > As just moved the GlobalNamingResources inside the
> > main <server> in my server.xml residing in
> > TOMCAT_HOME/conf directory. When i restart tomcat
> > 5.5.7 it's throwing up following exception.
> > INFO: Starting Servlet Engine: Apache Tomcat/5.5.7
> > Feb 22, 2005 11:51:46 AM
> > org.apache.catalina.realm.UserDatabaseRealm start
> > SEVERE: Exception looking up UserDatabase under
> key
> > UserDatabase
> > javax.naming.NameNotFoundException: Name
> UserDatabase
> > is not bound in this Conte
> > xt
> >         at
> >
>
org.apache.naming.NamingContext.lookup(NamingContext.java:769)
> >         at
> >
>
org.apache.naming.NamingContext.lookup(NamingContext.java:152)
> >         at
> >
>
org.apache.catalina.realm.UserDatabaseRealm.start(UserDatabaseRealm.j
> > ava:222)
> >         at
> >
>
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1003)
> > 
> >         at
> >
>
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:440
> > )
> >         at
> >
>
org.apache.catalina.core.StandardService.start(StandardService.java:4
> > 50)
> >         at
> >
>
org.apache.catalina.core.StandardServer.start(StandardServer.java:683
> > )
> >         at
> >
>
org.apache.catalina.startup.Catalina.start(Catalina.java:537)
> >         at
> >
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> > Method)
> >         at
> >
> sun.reflect.NativeMethodAccessorImpl.invoke(Unknown
> > Source)
> >         at
> >
>
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
> > Source)
> >         at java.lang.reflect.Method.invoke(Unknown
> > Source)
> >         at
> >
>
org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271)
> >         at
> >
>
org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409)
> > Feb 22, 2005 11:51:46 AM
> > org.apache.catalina.startup.Catalina start
> > SEVERE: Catalina.start:
> > LifecycleException:  No UserDatabase component
> found
> > under key UserDatabase
> >         at
> >
>
org.apache.catalina.realm.UserDatabaseRealm.start(UserDatabaseRealm.j
> > ava:228)
> >         at
> >
>
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1003)
> > 
> >         at
> >
>
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:440
> > )
> >         at
> >
>
org.apache.catalina.core.StandardService.start(StandardService.java:4
> > 50)
> >         at
> >
>
org.apache.catalina.core.StandardServer.start(StandardServer.java:683
> > )
> >         at
> >
>
org.apache.catalina.startup.Catalina.start(Catalina.java:537)
> >         at
> >
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> > Method)
> >         at
> >
> sun.reflect.NativeMethodAccessorImpl.invoke(Unknown
> > Source)
> >         at
> >
>
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
> > Source)
> >         at java.lang.reflect.Method.invoke(Unknown
> > Source)
> >         at
> >
>
org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271)
> >         at
> >
>
org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409)
> > Feb 22, 2005 11:51:46 AM
> > org.apache.catalina.startup.Catalina start
> > INFO: Server startup in 391 ms
> > 
> > Pls help to fix the problem.
> > 
> > Thanks,
> > Laxmi
> > 
> > --- Antony Paul <an...@gmail.com> wrote:
> > 
> > > It seems you still have problem. You can google
> for
> > > the answer. One
> > > thing I know is GlobalNamingResources should
> come
> > > inside the Server
> > > element and not inside Context element.
> > >
> > > rgds
> > > Antony Paul
> > >
> > >
> > > On Fri, 18 Feb 2005 22:47:06 -0800 (PST), U K
> Laxmi
> > > <la...@yahoo.com> wrote:
> > > > I could able to get thro' JarperException.
> Thanks
> > > for
> > > > replies.
> > > >
> > > > Now facing new problem.
> > > >
> > > > I'm getting "NameNotFoundException" -  Name
> jdbc
> > > is
> > > > not bound in this Context
> > > >
> > > > Environment what i'm using is: Apache 2,
> Tomcat
> > > 5.5,
> > > > Netscape 7.2, MsAccess 2003 on windows 2000
> > > machine.
> > > >
> > > > I integrated tomcat and apache as apache
> doesn't
> > > > support jsps. I wrote a JSP called test-db.jsp
> > > which
> > > > in turn calls java program TestSQLLoad.java.
> This
> > > > TestSQLLoad.java performs dattabase operation,
> > > fetches
> > > > the data from table and that data is displayed
> on
> > > > Netscape thro' jsp.
> > > >
> > > > 1. test-db.jsp resides ina directory
> > > > TOMCAT_HOME/webapps/web/JSP. Contents are as
> > > follows:
> > > >
> > > > <%@ page contentType="text/html"
> > > > import="testpkg.TestSQLLoad"%>
> > > >
> > > >         <html>
> > > >       <head>
> > > >         <title>DB Test</title>
> > > >       </head>
> > > >       <body>
> > > >
> > > >       <%
> > > >         TestSQLLoad tst = new TestSQLLoad();
> > > >         tst.init();
> > > >       %>
> > > >
> > > >       <h2>Results</h2>
> > > >         User -> <%= tst.getUser() %><br/>
> > > >         Pwd -> <%= tst.getPassword() %><br/>
> > > >         Id -> <%= tst.getID() %>
> > > >
> 
=== message truncated ===



	
		
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - You care about security. So do we. 
http://promotions.yahoo.com/new_mail

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Name jdbc is not bound in this Context error

Posted by Antony Paul <an...@gmail.com>.
By default server.xml contains have a  <GlobalNamingResources>. You
have to add your resources in there.

rgds
Antony Paul


On Mon, 21 Feb 2005 19:56:23 -0800 (PST), U K Laxmi <la...@yahoo.com> wrote:
> As just moved the GlobalNamingResources inside the
> main <server> in my server.xml residing in
> TOMCAT_HOME/conf directory. When i restart tomcat
> 5.5.7 it's throwing up following exception.
> INFO: Starting Servlet Engine: Apache Tomcat/5.5.7
> Feb 22, 2005 11:51:46 AM
> org.apache.catalina.realm.UserDatabaseRealm start
> SEVERE: Exception looking up UserDatabase under key
> UserDatabase
> javax.naming.NameNotFoundException: Name UserDatabase
> is not bound in this Conte
> xt
>         at
> org.apache.naming.NamingContext.lookup(NamingContext.java:769)
>         at
> org.apache.naming.NamingContext.lookup(NamingContext.java:152)
>         at
> org.apache.catalina.realm.UserDatabaseRealm.start(UserDatabaseRealm.j
> ava:222)
>         at
> org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1003)
> 
>         at
> org.apache.catalina.core.StandardEngine.start(StandardEngine.java:440
> )
>         at
> org.apache.catalina.core.StandardService.start(StandardService.java:4
> 50)
>         at
> org.apache.catalina.core.StandardServer.start(StandardServer.java:683
> )
>         at
> org.apache.catalina.startup.Catalina.start(Catalina.java:537)
>         at
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> Method)
>         at
> sun.reflect.NativeMethodAccessorImpl.invoke(Unknown
> Source)
>         at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
> Source)
>         at java.lang.reflect.Method.invoke(Unknown
> Source)
>         at
> org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271)
>         at
> org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409)
> Feb 22, 2005 11:51:46 AM
> org.apache.catalina.startup.Catalina start
> SEVERE: Catalina.start:
> LifecycleException:  No UserDatabase component found
> under key UserDatabase
>         at
> org.apache.catalina.realm.UserDatabaseRealm.start(UserDatabaseRealm.j
> ava:228)
>         at
> org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1003)
> 
>         at
> org.apache.catalina.core.StandardEngine.start(StandardEngine.java:440
> )
>         at
> org.apache.catalina.core.StandardService.start(StandardService.java:4
> 50)
>         at
> org.apache.catalina.core.StandardServer.start(StandardServer.java:683
> )
>         at
> org.apache.catalina.startup.Catalina.start(Catalina.java:537)
>         at
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> Method)
>         at
> sun.reflect.NativeMethodAccessorImpl.invoke(Unknown
> Source)
>         at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
> Source)
>         at java.lang.reflect.Method.invoke(Unknown
> Source)
>         at
> org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271)
>         at
> org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409)
> Feb 22, 2005 11:51:46 AM
> org.apache.catalina.startup.Catalina start
> INFO: Server startup in 391 ms
> 
> Pls help to fix the problem.
> 
> Thanks,
> Laxmi
> 
> --- Antony Paul <an...@gmail.com> wrote:
> 
> > It seems you still have problem. You can google for
> > the answer. One
> > thing I know is GlobalNamingResources should come
> > inside the Server
> > element and not inside Context element.
> >
> > rgds
> > Antony Paul
> >
> >
> > On Fri, 18 Feb 2005 22:47:06 -0800 (PST), U K Laxmi
> > <la...@yahoo.com> wrote:
> > > I could able to get thro' JarperException. Thanks
> > for
> > > replies.
> > >
> > > Now facing new problem.
> > >
> > > I'm getting "NameNotFoundException" -  Name jdbc
> > is
> > > not bound in this Context
> > >
> > > Environment what i'm using is: Apache 2, Tomcat
> > 5.5,
> > > Netscape 7.2, MsAccess 2003 on windows 2000
> > machine.
> > >
> > > I integrated tomcat and apache as apache doesn't
> > > support jsps. I wrote a JSP called test-db.jsp
> > which
> > > in turn calls java program TestSQLLoad.java. This
> > > TestSQLLoad.java performs dattabase operation,
> > fetches
> > > the data from table and that data is displayed on
> > > Netscape thro' jsp.
> > >
> > > 1. test-db.jsp resides ina directory
> > > TOMCAT_HOME/webapps/web/JSP. Contents are as
> > follows:
> > >
> > > <%@ page contentType="text/html"
> > > import="testpkg.TestSQLLoad"%>
> > >
> > >         <html>
> > >       <head>
> > >         <title>DB Test</title>
> > >       </head>
> > >       <body>
> > >
> > >       <%
> > >         TestSQLLoad tst = new TestSQLLoad();
> > >         tst.init();
> > >       %>
> > >
> > >       <h2>Results</h2>
> > >         User -> <%= tst.getUser() %><br/>
> > >         Pwd -> <%= tst.getPassword() %><br/>
> > >         Id -> <%= tst.getID() %>
> > >
> > >       </body>
> > >     </html>
> > >
> > > 2. TestSQLLoad.java is residing in following
> > > directory. TOMCAT_HOME/webapps/web/classes/testpkg
> > > direcotry. Contents of this file are as follows:
> > >
> > >         package testpkg;
> > >
> > >         import javax.naming.*;
> > >     import javax.sql.*;
> > >     import java.sql.*;
> > >
> > >     public class TestSQLLoad
> > >     {
> > >
> > >      String user = "Not Connected";
> > >      String pwd = "no pwd";
> > >      int id = -1;
> > >
> > >      public void init() {
> > >       try{
> > >        Context ctx = new InitialContext();
> > >        if(ctx == null ) {
> > >         throw new Exception("Boom - No Context");
> > >        }
> > >
> > >            Context envCtx = (Context)
> > > ctx.lookup("java:comp/env");
> > >        DataSource ds = (DataSource)
> > > envCtx.lookup("jdbc/db1");
> > >
> > >        //DataSource ds =
> > > (DataSource)ctx.lookup("java:comp/env/jdbc/db1");
> > >
> > >        if (ds != null) {
> > >         Connection conn = ds.getConnection();
> > >
> > >         if(conn != null) {
> > >          user = "Got Connection "+conn.toString();
> > >          Statement stmt = conn.createStatement();
> > >          String q = "select name, password, id
> > from
> > > user";
> > >          ResultSet rst = stmt.executeQuery(q);
> > >          if(rst.next()) {
> > >           user=rst.getString(1);
> > >           pwd=rst.getString(2);
> > >           id = rst.getInt(3);
> > >          }
> > >          conn.close();
> > >         }
> > >        }
> > >       }catch(Exception e) {
> > >        e.printStackTrace();
> > >       }
> > >      }
> > >
> > >      public String getUser() {
> > >       return user;
> > >      }
> > >
> > >      public String getPassword() {
> > >       return pwd;
> > >      }
> > >
> > >      public int getID()
> > >      {
> > >       return id;
> > >      }
> > >     }
> > >
> > > 3. I created a jar file using testpkg directory &
> > put
> > > it in TOMCAT_HOME/common/lib as well as
> > > TOMCAT_HOME/webapps/web/WEB-INF/lib directory.
> > >
> > > 4. I created MsAccess database called db1.mdb and
> > put
> > > it in TOMCAT_HOME/WEBAPPS/WEB/db1 directory. I
> > created
> > > a table called user with fields name, password and
> > ID.
> > > ID is the primary key.
> > >
> > > 5. I included following in the server.xml of
> > > TOMCAT_HOME/conf directory.
> > >
> > > <Context path="/db1"
> > docBase="C:/tomcat/webapps/db1"
> > >             debug="5" reloadable="true"
> > > crossContext="true">
> > >
> > > <GlobalNamingResources>
> > >   <Resource name="jdbc/db1" auth="Container"
> > >     type="javax.sql.DataSource"
> > >
> > >
> >
> factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
> > >     driverClassName="sun.jdbc.odbc.JdbcOdbcDrive"
> > >     url="jdbc:odbc://localhost/db1"
> > >         maxActive="20" maxIdle="10" maxWait="-1"
> > />
> > >         </GlobalNamingResources>
> > > </Context>
> > >
> > > 6. I included following in context.xml of
> > > TOMCAT_HOME/conf directory.
> > >
> > > <ResourceLink global="jdbc/db1" name="jdbc/db1"
> > > type="javax.sql.DataSource"/>
> > >
> > > 7. I included following in web.xml of
> > > TOMCAT_HOME/webapps/web/WEB-INF directory.
> > >
> > >    <resource-ref>
> > >         <res-ref-name>jdbc/db1</res-ref-name>
> > >         <res-type>javax.sql.DataSource</res-type>
> > >         <res-auth>Container</res-auth>
> > >     </resource-ref>
> > >
> > > 8. I copied commons-collections-2.1.1.jar,
> > > commons-dbcp-1.2.1.jar and commons-pool-1.2.jar
> > into
> > > TOMCAT_HOME/common/lib directory.
> > >
> > > 9. I started apache, tomcat and then opened a
> > browser
> > > and typed http://localhost/web/JSP/test-db.jsp.
> > >
> > > 10. I get following on the browser.
> > >
> > > "Results
> > > User -> Not Connected
> > > Pwd -> no pwd
> > > Id -> -1"
> > >
> > > 11. On the tomcat window where tomcat is running
> > i'm
> > > getting following error.
> > >
> > > javax.naming.NameNotFoundException: Name jdbc is
> > not
> >
> === message truncated ===
> 
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail - 250MB free storage. Do more. Manage less.
> http://info.mail.yahoo.com/mail_250
>

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Name jdbc is not bound in this Context error

Posted by U K Laxmi <la...@yahoo.com>.
As just moved the GlobalNamingResources inside the
main <server> in my server.xml residing in
TOMCAT_HOME/conf directory. When i restart tomcat
5.5.7 it's throwing up following exception.
INFO: Starting Servlet Engine: Apache Tomcat/5.5.7
Feb 22, 2005 11:51:46 AM
org.apache.catalina.realm.UserDatabaseRealm start
SEVERE: Exception looking up UserDatabase under key
UserDatabase
javax.naming.NameNotFoundException: Name UserDatabase
is not bound in this Conte
xt
        at
org.apache.naming.NamingContext.lookup(NamingContext.java:769)
        at
org.apache.naming.NamingContext.lookup(NamingContext.java:152)
        at
org.apache.catalina.realm.UserDatabaseRealm.start(UserDatabaseRealm.j
ava:222)
        at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1003)

        at
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:440
)
        at
org.apache.catalina.core.StandardService.start(StandardService.java:4
50)
        at
org.apache.catalina.core.StandardServer.start(StandardServer.java:683
)
        at
org.apache.catalina.startup.Catalina.start(Catalina.java:537)
        at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown
Source)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
Source)
        at java.lang.reflect.Method.invoke(Unknown
Source)
        at
org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271)
        at
org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409)
Feb 22, 2005 11:51:46 AM
org.apache.catalina.startup.Catalina start
SEVERE: Catalina.start:
LifecycleException:  No UserDatabase component found
under key UserDatabase
        at
org.apache.catalina.realm.UserDatabaseRealm.start(UserDatabaseRealm.j
ava:228)
        at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1003)

        at
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:440
)
        at
org.apache.catalina.core.StandardService.start(StandardService.java:4
50)
        at
org.apache.catalina.core.StandardServer.start(StandardServer.java:683
)
        at
org.apache.catalina.startup.Catalina.start(Catalina.java:537)
        at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown
Source)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
Source)
        at java.lang.reflect.Method.invoke(Unknown
Source)
        at
org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271)
        at
org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409)
Feb 22, 2005 11:51:46 AM
org.apache.catalina.startup.Catalina start
INFO: Server startup in 391 ms

Pls help to fix the problem.

Thanks,
Laxmi

--- Antony Paul <an...@gmail.com> wrote:

> It seems you still have problem. You can google for
> the answer. One
> thing I know is GlobalNamingResources should come
> inside the Server
> element and not inside Context element.
> 
> rgds
> Antony Paul
> 
> 
> On Fri, 18 Feb 2005 22:47:06 -0800 (PST), U K Laxmi
> <la...@yahoo.com> wrote:
> > I could able to get thro' JarperException. Thanks
> for
> > replies.
> > 
> > Now facing new problem.
> > 
> > I'm getting "NameNotFoundException" -  Name jdbc
> is
> > not bound in this Context
> > 
> > Environment what i'm using is: Apache 2, Tomcat
> 5.5,
> > Netscape 7.2, MsAccess 2003 on windows 2000
> machine.
> > 
> > I integrated tomcat and apache as apache doesn't
> > support jsps. I wrote a JSP called test-db.jsp
> which
> > in turn calls java program TestSQLLoad.java. This
> > TestSQLLoad.java performs dattabase operation,
> fetches
> > the data from table and that data is displayed on
> > Netscape thro' jsp.
> > 
> > 1. test-db.jsp resides ina directory
> > TOMCAT_HOME/webapps/web/JSP. Contents are as
> follows:
> > 
> > <%@ page contentType="text/html"
> > import="testpkg.TestSQLLoad"%>
> > 
> >         <html>
> >       <head>
> >         <title>DB Test</title>
> >       </head>
> >       <body>
> > 
> >       <%
> >         TestSQLLoad tst = new TestSQLLoad();
> >         tst.init();
> >       %>
> > 
> >       <h2>Results</h2>
> >         User -> <%= tst.getUser() %><br/>
> >         Pwd -> <%= tst.getPassword() %><br/>
> >         Id -> <%= tst.getID() %>
> > 
> >       </body>
> >     </html>
> > 
> > 2. TestSQLLoad.java is residing in following
> > directory. TOMCAT_HOME/webapps/web/classes/testpkg
> > direcotry. Contents of this file are as follows:
> > 
> >         package testpkg;
> > 
> >         import javax.naming.*;
> >     import javax.sql.*;
> >     import java.sql.*;
> > 
> >     public class TestSQLLoad
> >     {
> > 
> >      String user = "Not Connected";
> >      String pwd = "no pwd";
> >      int id = -1;
> > 
> >      public void init() {
> >       try{
> >        Context ctx = new InitialContext();
> >        if(ctx == null ) {
> >         throw new Exception("Boom - No Context");
> >        }
> > 
> >            Context envCtx = (Context)
> > ctx.lookup("java:comp/env");
> >        DataSource ds = (DataSource)
> > envCtx.lookup("jdbc/db1");
> > 
> >        //DataSource ds =
> > (DataSource)ctx.lookup("java:comp/env/jdbc/db1");
> > 
> >        if (ds != null) {
> >         Connection conn = ds.getConnection();
> > 
> >         if(conn != null) {
> >          user = "Got Connection "+conn.toString();
> >          Statement stmt = conn.createStatement();
> >          String q = "select name, password, id
> from
> > user";
> >          ResultSet rst = stmt.executeQuery(q);
> >          if(rst.next()) {
> >           user=rst.getString(1);
> >           pwd=rst.getString(2);
> >           id = rst.getInt(3);
> >          }
> >          conn.close();
> >         }
> >        }
> >       }catch(Exception e) {
> >        e.printStackTrace();
> >       }
> >      }
> > 
> >      public String getUser() {
> >       return user;
> >      }
> > 
> >      public String getPassword() {
> >       return pwd;
> >      }
> > 
> >      public int getID()
> >      {
> >       return id;
> >      }
> >     }
> > 
> > 3. I created a jar file using testpkg directory &
> put
> > it in TOMCAT_HOME/common/lib as well as
> > TOMCAT_HOME/webapps/web/WEB-INF/lib directory.
> > 
> > 4. I created MsAccess database called db1.mdb and
> put
> > it in TOMCAT_HOME/WEBAPPS/WEB/db1 directory. I
> created
> > a table called user with fields name, password and
> ID.
> > ID is the primary key.
> > 
> > 5. I included following in the server.xml of
> > TOMCAT_HOME/conf directory.
> > 
> > <Context path="/db1"
> docBase="C:/tomcat/webapps/db1"
> >             debug="5" reloadable="true"
> > crossContext="true">
> > 
> > <GlobalNamingResources>
> >   <Resource name="jdbc/db1" auth="Container"
> >     type="javax.sql.DataSource"
> > 
> >
>
factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
> >     driverClassName="sun.jdbc.odbc.JdbcOdbcDrive"
> >     url="jdbc:odbc://localhost/db1"
> >         maxActive="20" maxIdle="10" maxWait="-1"
> />
> >         </GlobalNamingResources>
> > </Context>
> > 
> > 6. I included following in context.xml of
> > TOMCAT_HOME/conf directory.
> > 
> > <ResourceLink global="jdbc/db1" name="jdbc/db1"
> > type="javax.sql.DataSource"/>
> > 
> > 7. I included following in web.xml of
> > TOMCAT_HOME/webapps/web/WEB-INF directory.
> > 
> >    <resource-ref>
> >         <res-ref-name>jdbc/db1</res-ref-name>
> >         <res-type>javax.sql.DataSource</res-type>
> >         <res-auth>Container</res-auth>
> >     </resource-ref>
> > 
> > 8. I copied commons-collections-2.1.1.jar,
> > commons-dbcp-1.2.1.jar and commons-pool-1.2.jar
> into
> > TOMCAT_HOME/common/lib directory.
> > 
> > 9. I started apache, tomcat and then opened a
> browser
> > and typed http://localhost/web/JSP/test-db.jsp.
> > 
> > 10. I get following on the browser.
> > 
> > "Results
> > User -> Not Connected
> > Pwd -> no pwd
> > Id -> -1"
> > 
> > 11. On the tomcat window where tomcat is running
> i'm
> > getting following error.
> > 
> > javax.naming.NameNotFoundException: Name jdbc is
> not
> 
=== message truncated ===



		
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - 250MB free storage. Do more. Manage less. 
http://info.mail.yahoo.com/mail_250

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Name jdbc is not bound in this Context error

Posted by Antony Paul <an...@gmail.com>.
It seems you still have problem. You can google for the answer. One
thing I know is GlobalNamingResources should come inside the Server
element and not inside Context element.

rgds
Antony Paul


On Fri, 18 Feb 2005 22:47:06 -0800 (PST), U K Laxmi <la...@yahoo.com> wrote:
> I could able to get thro' JarperException. Thanks for
> replies.
> 
> Now facing new problem.
> 
> I'm getting "NameNotFoundException" -  Name jdbc is
> not bound in this Context
> 
> Environment what i'm using is: Apache 2, Tomcat 5.5,
> Netscape 7.2, MsAccess 2003 on windows 2000 machine.
> 
> I integrated tomcat and apache as apache doesn't
> support jsps. I wrote a JSP called test-db.jsp which
> in turn calls java program TestSQLLoad.java. This
> TestSQLLoad.java performs dattabase operation, fetches
> the data from table and that data is displayed on
> Netscape thro' jsp.
> 
> 1. test-db.jsp resides ina directory
> TOMCAT_HOME/webapps/web/JSP. Contents are as follows:
> 
> <%@ page contentType="text/html"
> import="testpkg.TestSQLLoad"%>
> 
>         <html>
>       <head>
>         <title>DB Test</title>
>       </head>
>       <body>
> 
>       <%
>         TestSQLLoad tst = new TestSQLLoad();
>         tst.init();
>       %>
> 
>       <h2>Results</h2>
>         User -> <%= tst.getUser() %><br/>
>         Pwd -> <%= tst.getPassword() %><br/>
>         Id -> <%= tst.getID() %>
> 
>       </body>
>     </html>
> 
> 2. TestSQLLoad.java is residing in following
> directory. TOMCAT_HOME/webapps/web/classes/testpkg
> direcotry. Contents of this file are as follows:
> 
>         package testpkg;
> 
>         import javax.naming.*;
>     import javax.sql.*;
>     import java.sql.*;
> 
>     public class TestSQLLoad
>     {
> 
>      String user = "Not Connected";
>      String pwd = "no pwd";
>      int id = -1;
> 
>      public void init() {
>       try{
>        Context ctx = new InitialContext();
>        if(ctx == null ) {
>         throw new Exception("Boom - No Context");
>        }
> 
>            Context envCtx = (Context)
> ctx.lookup("java:comp/env");
>        DataSource ds = (DataSource)
> envCtx.lookup("jdbc/db1");
> 
>        //DataSource ds =
> (DataSource)ctx.lookup("java:comp/env/jdbc/db1");
> 
>        if (ds != null) {
>         Connection conn = ds.getConnection();
> 
>         if(conn != null) {
>          user = "Got Connection "+conn.toString();
>          Statement stmt = conn.createStatement();
>          String q = "select name, password, id from
> user";
>          ResultSet rst = stmt.executeQuery(q);
>          if(rst.next()) {
>           user=rst.getString(1);
>           pwd=rst.getString(2);
>           id = rst.getInt(3);
>          }
>          conn.close();
>         }
>        }
>       }catch(Exception e) {
>        e.printStackTrace();
>       }
>      }
> 
>      public String getUser() {
>       return user;
>      }
> 
>      public String getPassword() {
>       return pwd;
>      }
> 
>      public int getID()
>      {
>       return id;
>      }
>     }
> 
> 3. I created a jar file using testpkg directory & put
> it in TOMCAT_HOME/common/lib as well as
> TOMCAT_HOME/webapps/web/WEB-INF/lib directory.
> 
> 4. I created MsAccess database called db1.mdb and put
> it in TOMCAT_HOME/WEBAPPS/WEB/db1 directory. I created
> a table called user with fields name, password and ID.
> ID is the primary key.
> 
> 5. I included following in the server.xml of
> TOMCAT_HOME/conf directory.
> 
> <Context path="/db1" docBase="C:/tomcat/webapps/db1"
>             debug="5" reloadable="true"
> crossContext="true">
> 
> <GlobalNamingResources>
>   <Resource name="jdbc/db1" auth="Container"
>     type="javax.sql.DataSource"
> 
> factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
>     driverClassName="sun.jdbc.odbc.JdbcOdbcDrive"
>     url="jdbc:odbc://localhost/db1"
>         maxActive="20" maxIdle="10" maxWait="-1" />
>         </GlobalNamingResources>
> </Context>
> 
> 6. I included following in context.xml of
> TOMCAT_HOME/conf directory.
> 
> <ResourceLink global="jdbc/db1" name="jdbc/db1"
> type="javax.sql.DataSource"/>
> 
> 7. I included following in web.xml of
> TOMCAT_HOME/webapps/web/WEB-INF directory.
> 
>    <resource-ref>
>         <res-ref-name>jdbc/db1</res-ref-name>
>         <res-type>javax.sql.DataSource</res-type>
>         <res-auth>Container</res-auth>
>     </resource-ref>
> 
> 8. I copied commons-collections-2.1.1.jar,
> commons-dbcp-1.2.1.jar and commons-pool-1.2.jar into
> TOMCAT_HOME/common/lib directory.
> 
> 9. I started apache, tomcat and then opened a browser
> and typed http://localhost/web/JSP/test-db.jsp.
> 
> 10. I get following on the browser.
> 
> "Results
> User -> Not Connected
> Pwd -> no pwd
> Id -> -1"
> 
> 11. On the tomcat window where tomcat is running i'm
> getting following error.
> 
> javax.naming.NameNotFoundException: Name jdbc is not
> bound in this Context
>         at
> org.apache.naming.NamingContext.lookup(NamingContext.java:769)
>         at
> org.apache.naming.NamingContext.lookup(NamingContext.java:152)
>         at
> org.apache.naming.factory.ResourceLinkFactory.getObjectInstance(Resou
> rceLinkFactory.java:96)
>         at
> javax.naming.spi.NamingManager.getObjectInstance(Unknown
> Source)
>         at
> org.apache.naming.NamingContext.lookup(NamingContext.java:792)
>         at
> org.apache.naming.NamingContext.lookup(NamingContext.java:139)
>         at
> org.apache.naming.NamingContext.lookup(NamingContext.java:780)
>         at
> org.apache.naming.NamingContext.lookup(NamingContext.java:152)
>         at
> testpkg.TestSQLLoad.init(TestSQLLoad.java:22)
>         at
> org.apache.jsp.JSP.test_002ddb_jsp._jspService(org.apache.jsp.JSP.tes
> t_002ddb_jsp:54)
>         at
> org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99)
>         at
> javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>         at
> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper
> .java:325)
>         at
> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:2
> 95)
>         at
> org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
>         at
> javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>         at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
> icationFilterChain.java:252)
>         at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
> ilterChain.java:173)
>         at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
> alve.java:214)
>         at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
> alve.java:178)
>         at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
> ava:126)
>         at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
> ava:105)
>         at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
> ve.java:107)
>         at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
> a:148)
>         at
> org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:306)
> 
>         at
> org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:385)
>         at
> org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:745)
>         at
> org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.ja
> va:675)
>         at
> org.apache.jk.common.SocketConnection.runIt(ChannelSocket.java:868)
>         at
> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP
> ool.java:684)
>         at java.lang.Thread.run(Unknown Source)
> 
> 11. Actually if i see the source code of TestSQLLoad
> it's throwing error on line 22 where it's trying to
> get  datasource.
> 
> I've rpovided all the information that i can. Please
> help to solve my problem and connect to database thro'
> jsp successfully. Any help in this regard is highly
> appreciated.
> 
> Thanks in advance.
> 
> __________________________________
> Do you Yahoo!?
> The all-new My Yahoo! - What will yours do?
> http://my.yahoo.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org