see my jsp error dscon$jsp.java [67:1] cannot resolve symbol

[nobr]sir i want to use the datasource in my jsp page

i see tomcate help in connection pooling

then i set my server.xml and web.xml

server.xml

location = C:\Program Files\j2sdk_nb\netbeans3.5\tomcat406\conf\server.xml

code ==***

***********

- <Context path="/DBTest" docBase="DBTest" debug="5" reloadable="true" crossContext="true">

<Logger className="org.apache.catalina.logger.FileLogger" prefix="localhost_DBTest_log." suffix=".txt" timestamp="true" />

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

- <ResourceParams name="jdbc/myoracle">

- <parameter>

<name>factory</name>

<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>

</parameter>

- <parameter>

<name>driverClassName</name>

<value>oracle.jdbc.OracleDriver</value>

</parameter>

- <parameter>

<name>url</name>

<value>jdbc:oracle:thin:@127.0.0.1:1521:aamir</value>

</parameter>

- <parameter>

<name>username</name>

<value>scott</value>

</parameter>

- <parameter>

<name>password</name>

<value>tiger</value>

</parameter>

- <parameter>

<name>maxActive</name>

<value>20</value>

</parameter>

- <parameter>

<name>maxIdle</name>

<value>10</value>

</parameter>

- <parameter>

<name>maxWait</name>

<value>-1</value>

</parameter>

</ResourceParams>

</Context>

*******

web.xml

where my all file and my project

location = F:\oraclewithjavaconn\WEB-INF\web.xml

code ==***

***********

<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE web-app (View Source for full doctype...)>

- <resource-ref>

<description>Oracle Datasource example</description>

<res-ref-name>jdbc/myoracle</res-ref-name>

<res-type>javax.sql.DataSource</res-type>

<res-auth>Container</res-auth>

</resource-ref>

******

sir this is my jsp code for database instance in

F:\oraclewithjavaconn\conntest

*******

<HTML>

<%@ page import="java.sql.*,java.util.*" %>

<%

Context initContext = new InitialContext();

Context envContext = (Context)initContext.lookup("java:/comp/env");

DataSource ds = (DataSource)envContext.lookup("jdbc/myoracle");

Connection conn = ds.getConnection();

%>

TEST DONE!

</HTML>

*************

sir when i compli the page then system give me error

error*********

scon$jsp.java [67:1] cannot resolve symbol

symbol : class Context

location: class org.apache.jsp.dscon$jsp

Context initContext = new InitialContext();

^

dscon$jsp.java [67:1] cannot resolve symbol

symbol : class InitialContext

location: class org.apache.jsp.dscon$jsp

Context initContext = new InitialContext();

^

dscon$jsp.java [68:1] cannot resolve symbol

symbol : class Context

location: class org.apache.jsp.dscon$jsp

Context envContext = (Context)initContext.lookup("java:/comp/env");

^

dscon$jsp.java [68:1] cannot resolve symbol

symbol : class Context

location: class org.apache.jsp.dscon$jsp

Context envContext = (Context)initContext.lookup("java:/comp/env");

^

dscon$jsp.java [69:1] cannot resolve symbol

symbol : class DataSource

location: class org.apache.jsp.dscon$jsp

DataSource ds = (DataSource)envContext.lookup("jdbc/myoracle");

^

dscon$jsp.java [69:1] cannot resolve symbol

symbol : class DataSource

location: class org.apache.jsp.dscon$jsp

DataSource ds = (DataSource)envContext.lookup("jdbc/myoracle");

^

6 errors

Errors compiling dscon.

************

sir please give me idea how i use datasource in my jsp page

thank

aamir[/nobr]

[4444 byte] By [mfa786a] at [2007-11-26 16:11:38]
# 1

You are missing a few imports there. Those are JNDI classes which can be found in the javax.naming package.

add:

<%@ page import="javax.naming.Context" %>

<%@ page import="javax.naming.InitialContext" %>

<%@ page import="javax.sql.DataSource" %>

That should fix the errors.

In the future when you get these kind of compilation errors, be sure to check the javadocs for the correct package for the needed classes.

http://java.sun.com/javase/6/docs/api/

gimbal2a at 2007-7-8 22:34:09 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

hi master

sir i not change in sever.xml and web.xml

some body give me idea i change in only Context.xml in META-INF folder

this is Context.xml code

<?xml version="1.0" encoding="UTF-8" ?>

<Context path="/dcp" privileged="true">

<Resource name="jdbc/postgres" auth="Container"

type=" javax.sql.DataSource"

driverClassName="oracle.jdbc.driver.OracleDriver"

url="jdbc:oracle:thin:@127.0.0.1:1521:aamir"

username="muhammad" password="mfa786" maxActive="1" maxIdle="0" maxWait="-1"/>

</Context>

*********

and this is my jsp code

<HTML>

<%@ page import="java.sql.*,java.util.*" %>

<%@ page import="javax.sql.DataSource" %>

<%@ page import="javax.naming.Context" %>

<%@ page import="javax.naming.InitialContext"%>

<%

Context initContext = new InitialContext();

DataSource ds = (DataSource)initContext.lookup("java:comp/env/jdbc/myOracleDataSource");

Connection conn = ds.getConnection();

%>

TEST DONE!

</HTML>

but sir jsp page give me error

javax.servlet.ServletException: Name jdbc is not bound in this Context

please give me idea how i run my jsp page

thank'

aamir

mfa786a at 2007-7-8 22:34:09 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...