You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by Lorenzo Sicilia <ar...@kemen.it> on 2003/03/03 11:17:38 UTC

jstl & dataSource

hi,

I had try to use dataSource in sql TAG but...

"Unable to get COnnection, Datasource ivalid:'no suitable driver' "

It is strage because in another application (Flash Remoting) I use the 
same driver perfectly.

I work with
JRUN4 and Apache 2.44 on windowsXP (staging) jvm 1.4.1
JRUN4 ang Apache 2.40 LInux (production) jvm 1.4.1


my script:

1)
<sql:setDataSource
dataSource="aosta" scope="request" />

<sql:query var="test" dataSource="aosta" >
SELECT *
FROM users
</sql:query>

<c:forEach items="${test.rows}" var="row">
<c:out value="${row.username}"/>
</c:forEach>

2)
<sql:query var="test" dataSource="aosta" >
SELECT *
FROM users
</sql:query>

<c:forEach items="${test.rows}" var="row">
<c:out value="${row.username}"/>
</c:forEach>


Both don't work :o(

Some one can help me?

thanks in advance

Lorenzo Sicilia


---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: jstl & dataSource

Posted by Ivonne Barrantes <ib...@ods.co.cr>.
I've had that same problem a few days ago.

Besides the code you already typed (which seems to be ok) you will need to 
have:

1)  The library (.jar) under your JSP container's specific sub directory
         (e.g.  d:\tomcat\common\lib).  Not on your application (so it 
works from any other application you want to create on the future)

2) A .xml file (named exactly the same as your context with the 
specification of your connection.

<Resource name="jdbc/DailyUsers" auth="Container" 
type="javax.sql.DataSource" />
<ResourceParams name="jdbc/DailyUsers">
         <parameter>
                 <name>factory</name>
                 <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
         </parameter>
         <parameter>
                 <name>driverClassName</name>
                 <value>org.postgresql.Driver</value>
         </parameter>
         <parameter>
                 <name>url</name>
                 <value>jdbc:postgresql://localhost:5432/users</value>
         </parameter>
         <parameter>
                 <name>username</name>
                 <value>abcdef</value>
         </parameter>
         <parameter>
                 <name>password</name>
                 <value>123456789</value>
         </parameter>
         <parameter>
                 <name>maxActive</name>
                 <value>20</value>
         </parameter>
         <parameter>
                 <name>maxIdle</name>
                 <value>10</value>
         </parameter>
         <parameter>
                 <name>maxWait</name>
                 <value>-1</value>
         </parameter>
</ResourceParams>


This examples uses a postgres jdbc,  you might change drivers & stuff for 
your own jdbc.

Good look!!!