Mr Craig,
   I  configure a JNDI in Tomcat5.5.12 like you tell me,like follows:

<Context path="" docBase="/jsp-examples" debug="5" reloadable="true"
crossContext="true">
    <Resource name="jdbc/bb1" auth="Container" type=" javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000" username="administrator"
password="123" driverClassName="sun.jdbc.odbc.JdbcOdbcDriver"
url="jdbc:odbc:SMS"/>
    </Context>

Then I call this JNDI in a JSP file,the JSP file is follows:

<[EMAIL PROTECTED] <[EMAIL PROTECTED]> <[EMAIL PROTECTED]@page> 
import="java.sql.*"%>
<[EMAIL PROTECTED] <[EMAIL PROTECTED]> import="javax.sql.DataSource"%>
< [EMAIL PROTECTED] <[EMAIL PROTECTED]> import="javax.naming.*"%>
<html>
<body>
<%
 try{
  Context initCtx=new InitialContext();
  System.out.println("ok");
  DataSource db = (DataSource)initCtx.lookup("java:comp/env/jdbc/bb1");
  System.out.println("db="+db);
  Connection conn = db.getConnection();
  System.out.println("conn="+conn);
  Statement stmt = conn.createStatement();
  ResultSet rs = stmt.executeQuery ("SELECT * FROM abc");
  out.println("User-list"+"<br>");
  while(rs.next()){
   out.print(rs.getString(1)+"<br>");
  }
  rs.close();
  stmt.close();
  conn.close();
 }catch(Exception e){
  out.print(e);
 }
%>
</body>
</html>



javax.naming.NameNotFoundException: Name jdbc is not bound in this Context

Why?
 Any idea will be appreciated!

Best regards,


On 4/4/06, Craig McClanahan <[EMAIL PROTECTED]> wrote:
>
> On 4/3/06, red phoenix <[EMAIL PROTECTED]> wrote:
> >
> > My Struts is 1.2.9,and tomcat is 5.5.15,and JDK is 1.5,I want to use
> > Struts
> > Datasource,my database is Microsoft Access 2000,and I have configured
> ODBC
> > datasource in windows,when I run it, it raise follows error:
> > type Status report
> > message Servlet action is not available
> > description The requested resource (Servlet action is not available) is
> > not
> > available.
>
>
> "Servlet action is not available" almost always means that some exception
> was thrown as the Struts action servlet was first initialized.  The
> exception will be logged in one of the Tomcat log files
> ($CATALINA_HOME/logs/*).
>
> In your particular case, the most likely problem is trying to use the
> Struts
> data source.  This functionality was deprecated in Struts 1.1, and was
> removed in Struts 1.2.  You should use the JNDI data sources provided by
> your container (Tomcat) instead.  There is pretty reasonable documentation
> on the Tomcat web site for how to set this stuff up, which applies to all
> webapps, not just Struts based ones.
>
>
>
> http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html
>
> Historical note -- the only reason Struts 1.0 supplied a data source
> implementation in the first place was that, six years ago, most servlet
> containers did not support JNDI based resource access.  Now that they
> (essentially) all do support JNDI, that is the recommended mechanism for
> managing data sources.
>
> Craig
>
>

Reply via email to