You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Lindomar <li...@bol.com.br> on 2002/09/29 20:40:53 UTC
Datasource
Hi everybody!
I'm using this code for connect my app in tomcat 4.1:
$$$$$$$$
...
Connection conn = null;
InitialContext ic = new InitialContext();
DataSource ds = (DataSource)ic.lookup("myjndi")
conn = ds.getConnection();
...
$$$$$$$$$
I configurate my connection in Adminitration Tool of tomcat.
For JNDI Name i set to "myjndi"
Until here ok, but when i start my app, appears exception:
Name myjndi is not bound in this Context
Any idea for this problem?
Thanks in advanced.
Re: Datasource
Posted by Willian Mitsuda <wm...@yahoo.com.br>.
Try this:
DataSource ds = (DataSource) ic.lookup("java:comp/env/myjndi");
but you should use this (note the "/jdbc" before "/myjndi"):
DataSource ds = (DataSource) ic.lookup("java:comp/env/jdbc/myjndi");
and bind your datasource to the name "jdbc/myjndi".
All environment resources are bind to the root naming context
"java:comp/env".
The specs sugests to use the naming context "jdbc" for datasources.
----- Original Message -----
From: "Lindomar" <li...@bol.com.br>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Sunday, September 29, 2002 3:40 PM
Subject: Datasource
Hi everybody!
I'm using this code for connect my app in tomcat 4.1:
$$$$$$$$
...
Connection conn = null;
InitialContext ic = new InitialContext();
DataSource ds = (DataSource)ic.lookup("myjndi")
conn = ds.getConnection();
...
$$$$$$$$$
I configurate my connection in Adminitration Tool of tomcat.
For JNDI Name i set to "myjndi"
Until here ok, but when i start my app, appears exception:
Name myjndi is not bound in this Context
Any idea for this problem?
Thanks in advanced.
_______________________________________________________________________
Yahoo! GeoCities
Tudo para criar o seu site: ferramentas fáceis de usar, espaço de sobra e acessórios.
http://br.geocities.yahoo.com/
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Datasource
Posted by Lindomar <li...@bol.com.br>.
Hi Miguel, thanks for your help...
I placed this code in web.xml, but don't work yet.
***
resource-ref>
<description>My datasource</description>
<res-ref-name>myjndi</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
***
I searched something about this, and is exactly this procedure.
I checked the server.xml and web.xml files, they are ok.
Server.xml
####
...
<Resource name="myjndi" scope="Shareable"
type="javax.sql.DataSource"/>
<ResourceParams name="myjndi">
<parameter>
<name>validationQuery</name>
<value></value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:db2:mydatabase</value>
</parameter>
<parameter>
<name>password</name>
<value>mypasswd</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>4</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>10</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>COM.ibm.db2.jdbc.app.DB2Driver</value>
</parameter>
<parameter>
<name>username</name>
<value>myuser</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>2</value>
</parameter>
</ResourceParams>
...
###
----- Original Message -----
From: "Miguel Angel Mulero Martinez" <mi...@mad.tecsidel.es>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Monday, September 30, 2002 11:27 AM
Subject: RE: Datasource
> You must define the DataSource in your web.xml too. For example:
>
> <resource-ref>
> <description>My datasource</description>
> <res-ref-name>myjndi</res-ref-name>
> <res-type>javax.sql.DataSource</res-type>
> <res-auth>Container</res-auth>
> </resource-ref>
>
> Regards.
>
> -----Mensaje original-----
> De: Lindomar [mailto:lindomar.silva@bol.com.br]
> Enviado el: domingo, 29 de septiembre de 2002 20:41
> Para: Tomcat Users List
> Asunto: Datasource
>
> Hi everybody!
> I'm using this code for connect my app in tomcat 4.1:
> $$$$$$$$
> ...
> Connection conn = null;
> InitialContext ic = new InitialContext();
> DataSource ds = (DataSource)ic.lookup("myjndi")
> conn = ds.getConnection();
> ...
> $$$$$$$$$
> I configurate my connection in Adminitration Tool of tomcat.
> For JNDI Name i set to "myjndi"
>
> Until here ok, but when i start my app, appears exception:
> Name myjndi is not bound in this Context
>
> Any idea for this problem?
>
> Thanks in advanced.
>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: Datasource
Posted by Miguel Angel Mulero Martinez <mi...@mad.tecsidel.es>.
You must define the DataSource in your web.xml too. For example:
<resource-ref>
<description>My datasource</description>
<res-ref-name>myjndi</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
Regards.
-----Mensaje original-----
De: Lindomar [mailto:lindomar.silva@bol.com.br]
Enviado el: domingo, 29 de septiembre de 2002 20:41
Para: Tomcat Users List
Asunto: Datasource
Hi everybody!
I'm using this code for connect my app in tomcat 4.1:
$$$$$$$$
...
Connection conn = null;
InitialContext ic = new InitialContext();
DataSource ds = (DataSource)ic.lookup("myjndi")
conn = ds.getConnection();
...
$$$$$$$$$
I configurate my connection in Adminitration Tool of tomcat.
For JNDI Name i set to "myjndi"
Until here ok, but when i start my app, appears exception:
Name myjndi is not bound in this Context
Any idea for this problem?
Thanks in advanced.
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>