Hi

The ResourceLink element will use the parameters name, global and type.
Everything else is being ignored, as the resource link is but reference to the global shared data source. See http://tomcat.apache.org/tomcat-7.0-doc/config/context.html, searching for ResourceLink.

Best regards

On 5/23/2012 9:31 PM, Robert Anderson wrote:
Hi,

I'm testing this functionality (versions 6.0.35 and 7.0.27) but it's not
working for me (https://issues.apache.org/bugzilla/show_bug.cgi?id=49543 ,
http://tomcat.apache.org/tomcat-7.0-doc/config/context.html#Resource_Links).


-->server.xml


   <GlobalNamingResources>

     <Resource name="jdbc/globalpg" auth="Container"
type="javax.sql.DataSource" removeAbandoned="true"
removeAbandonedTimeout="300"
                                    maxActive="400" maxIdle="30"
maxWait="10000"
                                    validationQuery="select 1"
                                    testOnBorrow="true"

factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
                                    driverClassName="org.postgresql.Driver"
                                    url="jdbc:postgresql://
172.17.1.5:5432/tjse"
                                    username="user1"
                                    password="validpassword"
                                    />

   </GlobalNamingResources>


-->conf/Catalina/localhost/app1.xml


<Context>

     <ResourceLink name="jdbc/localpg"
     global="jdbc/globalpg"
     type="javax.sql.DataSource"
     factory="org.apache.naming.factory.DataSourceLinkFactory"
     username="user2"
     password="invalidpassword"
     />

</Context>


-->webapps/app1/index.jsp

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
<%@ page session="false" import="javax.naming.*, java.sql.*, javax.sql.*" %>
<html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">
     <head>
     <title>Test shared data source</title>
</head>
<body>
<%
     Context ctx = new InitialContext();
     DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/localpg");
     Connection c = ds.getConnection();
     Statement stm = c.createStatement();

     ResultSet rs = stm.executeQuery("select 'this should fail because the
password of localpg is invalid but it is working.'");

     rs.next();

%>
     <%= rs.getString(1) %><br/>
<%

     c.close();
%>
</body>
</html>


Am I doing some wrong?


Thanks in advance,


Robert


--
*João Silva
* *
VILT Group
* *_http://www.vilt-group.com
_
Rua Ivone Silva, 6 - 7º Esq
1050-124 Lisboa - Portugal

Mobile  +351 926 531 097
Phone   +351 210 34 33 00
Fax       +351 210 34 33 99
Email _joao.si...@vilt-group.com <mailto:joao.si...@vilt-group.com>_*

Reply via email to