-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Elanora,

[EMAIL PROTECTED] wrote:
> When I use 
> <sql:query var="rs" dataSource="jdbc/TestDB">
> I get:
> javax.servlet.ServletException: Unable to get connection, DataSource invalid: 
> "java.sql.SQLException: No suitable driver found for jdbc/TestDB"

I suspect it is because your configuration is broken. But, your JSP
should certainly mention the DataSource name, not the URL for the
DataSource.

According to the JSTL documentation
(http://java.sun.com/products/jsp/jstl/1.1/docs/tlddocs/index.html),
"dataSource" is:

"
Data source associated with the database to query. A String value
represents a relative path to a JNDI resource or the parameters for the
DriverManager class.
"

I'm not sure what that second part means (after the "or"), but it will
certainly work if you have a JNDI DataSource mentioned. Using JNDI
DataSources will be much better, too, because then you can use your
connection pool instead of creating a new connection for every run of
the JSP. If you aren't using a connection pool, you are asking for an
OOME or DOS attack.

Where have you placed the JAR file containing com.mysql.jdbc.Driver?
Since you put your <Resource> configuration in server.xml, you need to
have connector-j-x.y.z.jar in Tomcat's common/lib or server/lib
directories (I always use common/lib). DO NOT PUT THIS SAME JAR FILE
INTO YOUR WEBAPP'S WEB-INF/lib DIRECTORY: the JAR file should appear in
only one place.

>                            <parameter>
>                                    <name>driverClassName</name>
>                                    <value>com.mysql.jdbc.Driver</value>
>                            </parameter>
>                            
>                            <parameter>
>                                    <name>url</name>
>                                    
> <value>jdbc:mysql://localhost:3306/javatest?autoReconnect=true</value>
>                            </parameter>


I know that the Tomcat documentation says to use "autoReconnect", but it
is wrong, wrong, wrong. Mark Matthews and MySQL both agree that everyone
should stop using that parameter, and instead use proper connection
checking in your connection pool. You need to use a "validationQuery"
set to something simple like "SELECT 1". I believe newer versions of the
driver actually support "PING" which does even less work, but has the
same effect of ensuring that the connection is good.

Hope that helps,
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkilm9cACgkQ9CaO5/Lv0PCYqQCgmbtFY/6e1vKocPFc+rrGpUwf
mFwAniTFNLa0v9BuZ17lqCEGUwwJEzI+
=0j0O
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to