users@glassfish.java.net

Can't make use of a defined oracle datasource

From: <glassfish_at_javadesktop.org>
Date: Fri, 14 Mar 2008 07:54:28 PST

Hi everybody,

I've defined an oracle data source in the GF admin console. Here is some info that might be relevant.

Firstly in Resouces->JDBC->Connection Pools I created a connection pool named 'as_06'.

Datasource Classname: oracle.jdbc.pool.OracleConnectionPoolDataSource

Resource Type: javax.sql.ConnectionPoolDataSource

In additional properties I set User, Password, Data Source name (as_06), URL.

Secondly, in Resouces->JDBC Resouces-> I added: JNDI name: jdbc/as_06

When back in Resouces->JDBC->Connection Pools I pressed Ping I got a the Ping succeeded confirmation



Now, in Eclipse, I am testing the data source with the following piece of code (file part4.jsp)

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

<%
String sql = "SELECT * from tbl_1";

try
 {
  DataSource ds = (DataSource)new InitialContext().lookup("jdbc/as_06");
  Connection con = ds.getConnection();
  Statement st = con.createStatement();
  ResultSet rs = st.executeQuery(sql);

  while(rs.next())
   {
    out.println("numb=" + rs.getString("nm_treatment_code"));
    out.println("; text=" + rs.getString("vc_treatment_desc") + "<br>");
   }
   
  st.close();
 }

catch (ClassNotFoundException e)
 {
  System.out.println("CNF_err=" + e);
 }
catch (SQLException e)
 {
  System.out.println("SQLE_err=" + e);
 }
%>


And here are the error messages I am getting in the browser:


org.apache.jasper.JasperException: PWC6033: Unable to compile class for JSP

PWC6197: An error occurred at line: 11 in the jsp file: /part4.jsp
PWC6199: Generated servlet error:
string:///index_jsp.java:77: cannot find symbol
symbol : class DataSource
location: class org.apache.jsp.index_jsp

PWC6197: An error occurred at line: 11 in the jsp file: /part4.jsp
PWC6199: Generated servlet error:
string:///index_jsp.java:77: cannot find symbol
symbol : class DataSource
location: class org.apache.jsp.index_jsp

PWC6197: An error occurred at line: 11 in the jsp file: /part4.jsp
PWC6199: Generated servlet error:
string:///index_jsp.java:77: cannot find symbol
symbol : class InitialContext
location: class org.apache.jsp.index_jsp


Could you please direct me on the right track, what am I doing wrong?

Thanks,
Alex
[Message sent by forum member 'cadol' (cadol)]

http://forums.java.net/jive/thread.jspa?messageID=264055