Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Can't use DataSource from Oracle Application Server

Can't use DataSource from Oracle Application Server

From: <Tural.Muradbeyli_at_gmail.com>
Date: 13 Feb 2007 06:58:53 -0800
Message-ID: <1171378733.430006.276070@a34g2000cwb.googlegroups.com>


I have created DataSource on Oracle Application Server 10R Release 3 (10.1.3) using Application Server Web Manager interface. When I test connection, the result is successfully. But when I use this data source in my application, error occurs:

javax.naming.NameNotFoundException: java:comp/env/jdbc/ccs_uniutf1 not found in CCS
com.oracle.naming.J2EEContext.getSubContext(J2EEContext.java:183)

web.xml file of my application:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app>

   <filter>

<filter-name>CharacterEncodingFilter</filter-name>
<filter-class>az.unibank.Misc.CharacterEncodingFilter</filter-
class>

   </filter>

   <filter-mapping>

<filter-name>CharacterEncodingFilter</filter-name>
<url-pattern>/servlet/*</url-pattern>
</filter-mapping> <filter-mapping>
<filter-name>CharacterEncodingFilter</filter-name>
<url-pattern>*.jsp</url-pattern>

   </filter-mapping>
   <filter-mapping>

<filter-name>CharacterEncodingFilter</filter-name>
<url-pattern>*.html</url-pattern>
</filter-mapping> <filter-mapping>
<filter-name>CharacterEncodingFilter</filter-name>
<url-pattern>*.htm</url-pattern>

   </filter-mapping>

   <!-- top of web.xml file -->
   <resource-ref>

<description>Data Source for UNIUTF1.CCS</description>
<res-ref-name>jdbc/ccs_uniutf1</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>

   </resource-ref>
   <!-- rest of web.xml file -->
</web-app>

   public static LoginManager Authorize(String login, String password) throws Exception

   {

      DataSource pool;
      Context env;
      Connection con = null;
      PreparedStatement ps = null;
      ResultSet rs = null;
      LoginManager lm = null;
      try
      {
         env = (Context)new InitialContext().lookup("java:comp/env");
         //Look up a DataSource, which represents a connection pool
         pool = (DataSource)env.lookup("jdbc/ccs_uniutf1");
         //Get a Connection from the connection pool
         con = pool.getConnection();
         ps = con.prepareStatement("SELECT name, login, password,
email FROM cc_users WHERE login = ? AND disabled = 0");
         ps.setString(1, login);
         rs = ps.executeQuery();
         if(rs.next())
         {
            if(!password.equals(rs.getString("password")))
            {
               throw new InvalidPasswordException();
            }
         }
         else
         {
            throw new InvalidUserNameException(login);
         }
         lm = new LoginManager(rs.getString("name"),
rs.getString("login"), rs.getString("email"));
      }
      finally
      {
         if(rs != null) rs.close();
         if(ps != null) ps.close();
         if((con != null) && (!con.isClosed())) con.close();
      }
      return lm;

   }

http://serv2.imagehigh.com/imgss/5057806_ps1.png Received on Tue Feb 13 2007 - 08:58:53 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US