tomcat 5.5.4 & datasource error: no suitable driver found

Discussion in 'Java' started by shahbazc@gmail.com, Jan 11, 2005.

  1. Guest

    Hi,
    I am running tomcat 5.5.4 and trying to use JSTL sql tag. I setup a
    data source though Tomcat's admin web-app for Postgresql (8 beta). I
    made sure the jdbc jar is in common/lib (I even specifically added it
    to the class path through setclasspath.sh). I still get a
    "java.sql.SQLException: No suitable driver" exception.

    I tested the jdbc driver using jdbctester...because of that I'm pretty
    sure the driver works. I copied the URL format from jdbctester to
    tomcat (some online references suggested that the url might be
    malformed), but it still doesn't work!

    Following is some relevant information:

    test.jsp (I DON'T get any exception in the code between <% and %>
    tags!):---------------------------------------------
    <html>
    <head>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>

    </head>
    <body>
    <%
    org.postgresql.jdbc3.Jdbc3PoolingDataSource source=new
    org.postgresql.jdbc3.Jdbc3PoolingDataSource();
    source.setDataSourceName("ssx");
    source.setServerName("localhost");
    source.setDatabaseName("ss");
    source.setUser("postgres");

    out.println(new org.postgresql.Driver());
    %>
    <sql:setDataSource driver="org.postgresql.Driver"
    url="jdbc:postgresql://localhost/ss"
    user="postgres" dataSource="new
    org.postgresql.jdbc3.Jdbc3PoolingDataSource()"
    var="ds" scope="session" />


    <sql:query var="result" dataSource="jdbc/postgres"
    sql="select symbol,sum(orders) from loaddata where month=200411 group
    by symbol"/>

    <table>
    <c:forEach items="$result.rows}" var="row">
    <tr><td>hello!</td></tr>
    </c:forEach>
    </table>

    </body>
    </html>

    web.xml:-------------------------------------
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
    http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
    version="2.4">

    <display-name>Hello, World Application</display-name>
    <description>
    This is a simple web application with a source code
    organization
    based on the recommendations of the Application Developer's
    Guide.
    </description>

    <servlet>
    <servlet-name>HelloServlet</servlet-name>
    <servlet-class>mypackage.Hello</servlet-class>
    </servlet>

    <servlet-mapping>
    <servlet-name>HelloServlet</servlet-name>
    <url-pattern>/hello</url-pattern>
    </servlet-mapping>

    <taglib>
    <taglib-uri>http://jakarta.apache.org/taglibs/sql</taglib-uri>
    <taglib-location>/WEB-INF/tld/sql.tld</taglib-location>
    </taglib>

    <taglib>
    <taglib-uri>http://jakarta.apache.org/taglibs/core</taglib-uri>
    <taglib-location>/WEB-INF/tld/c.tld</taglib-location>
    </taglib>

    <!--I explicitly added this resource-ref, hopeing that this would fix
    my problem-->
    <resource-ref>
    <description>postgreSQL Datasource example</description>
    <res-ref-name>jdbc/postgres</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>
    </web-app>


    server.xml:---------------------
    <?xml version='1.0' encoding='utf-8'?>
    <Server>
    <Listener
    className="org.apache.catalina.mbeans.ServerLifecycleListener"/>
    <Listener
    className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
    <GlobalNamingResources>
    <Environment name="simpleValue" type="java.lang.Integer"
    value="30"/>
    <Resource auth="Container" description="User database that can be
    updated and saved" name="UserDatabase"
    type="org.apache.catalina.UserDatabase"
    pathname="conf/tomcat-users.xml"
    factory="org.apache.catalina.users.MemoryUserDatabaseFactory"/>
    <Resource name="jdbc/postgres" type="javax.sql.DataSource"
    driverClassName="org.postgresql.Driver" password="" maxIdle="2"
    maxWait="5000" validationQuery="select count(*) from loaddata where
    month=200411" username="postgres" url="jdbc:postgresql://localhost/ss"
    maxActive="4"/>
    </GlobalNamingResources>
    <Service name="Catalina">
    <Connector port="8080" redirectPort="8443" maxSpareThreads="75"
    maxThreads="150" minSpareThreads="25">
    </Connector>
    <Connector port="8009" protocol="AJP/1.3"
    protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"
    redirectPort="8443">
    </Connector>
    <Engine defaultHost="localhost" name="Catalina">
    <Host appBase="webapps" name="localhost">
    </Host>
    <Realm className="org.apache.catalina.realm.UserDatabaseRealm"/>
    </Engine>
    </Service>
    </Server>


    By the way, this seemed like the most relevant newsgroup, if there is a
    better source for help, please let me know. Thanks!
     
    , Jan 11, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Timo Nentwig

    DB2: no suitable driver

    Timo Nentwig, Sep 20, 2003, in forum: Java
    Replies:
    9
    Views:
    11,352
    Hugo Pragt
    Sep 23, 2003
  2. JD Uhler
    Replies:
    5
    Views:
    6,735
    Thomas Fritsch
    Feb 4, 2004
  3. Andrew Johnson
    Replies:
    2
    Views:
    4,705
    Sudsy
    Oct 20, 2004
  4. jborup
    Replies:
    2
    Views:
    597
    jborup
    Feb 4, 2007
  5. Replies:
    1
    Views:
    602
Loading...

Share This Page