You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by John de la Garza <jd...@designinsites.com> on 2001/03/05 22:14:27 UTC

need help with DataSource

 Can some one help me understand what's going on here?
  Or point me to some
 docs?
 
 I am using tomcat as my servlet container.
 

------------------------------------------------------------------------
 In my server.xml I have this:
 <resource-ref>
   <res-ref-name>jdbc/roiad</res-ref-name>
   <res-type>javax.sql.DataSource</res-type>
   <init-param
   <driver-name="org.gjt.mm.mysql.Driver"/>
   <init-param url="jdbc:mysql://172.16.12.1/roiad"/>
   <init-param user="roiad"/>
   <init-param password=""/>
   <init-param max-connections="20"/>
   <init-param enable-transaction="false"/>
 </resource-ref>

---------------------------------------------------------------------------
 then in my code I try to get to the database like
 this:
 
  Context  ctx=new InitialContext();
   DataSource 
 ds=(DataSource)ctx.lookup("jdbc/roiad");
    Connection  con=ds.getConnection();
 
 I get this error message:
 
 javax.naming.NoInitialContextException: Need to
 specify class name in
 environmen
 t or system property, or as an applet parameter, or
 in an application
 resource f
 ile:  java.naming.factory.initial
 
 
 I am trying to follow an example in book, but it is
 just not working...any ideas?