How do I get my web application to connect to mysql again?

Posted on 2007-10-07
Last Modified: 2011-04-14
I am having this weird issue with my jsp application when trying to connect to mysql. It started to occur when I migrated from netbeans 5.5 to the netbeans 6 beta... in 5.5 I was using tomcat is the integrated j2ee server, however, in 6 they now use sun java application server 9.1, somewhere between the two my application stopped being to read the mysql database even though the connector jar is included in the package as a library. Here is what I get when I attempt to login to my application:

HTTP Status 500 -

type Exception report


descriptionThe server encountered an internal error () that prevented it from fulfilling this request.


javax.servlet.ServletException: javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: "java.sql.SQLException: No suitable driver found for jdbc:mysql://"

root cause

javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: "java.sql.SQLException: No suitable driver found for jdbc:mysql://"

note The full stack traces of the exception and its root causes are available in the Sun Java System Application Server 9.1 logs.
Sun Java System Application Server 9.1

Again the mysql connector is already included in the package.. so that fact that it cannot find a driver is beyond me.

A working fix to this problem is worth 500 points.

Question by:richardsimnett
    LVL 23

    Expert Comment

    Looking at this exception message, suggests that the driver is not there in
    the classpath or not bundled with the application.

    Author Comment

    I dont know why that would be a problem. I thought it was a class path issue as well, tahts why I double checked to make sure the jar was included in the package as a library. I have also investigated the .war file for the application, and the mysql-connector is there in the /WEB-INF/lib directory.... so I have no idea what the issue is.

    LVL 23

    Expert Comment

    can you post the code where you are making the connection?

    Author Comment

    <%-- manage a login attempt --%>
    <%@taglib uri="" prefix="c"%>
    <%@taglib uri="" prefix="sql"%>

    <%-- set up the datasource --%>
    <sql:setDataSource var="dblogin" url="jdbc:mysql://" driver="com.mysql.jdbc.Driver" user="pdev" password="pdev2k7"></sql:setDataSource>

    <%-- first query the database for the username and password --%>
    <sql:query var="login" dataSource="${dblogin}">
        select id from users where username='${param.username}' and password='${param.password}'  

    Accepted Solution

    nm got it... had to copy the mysql-connector.jar to the JRE's classpath /lib/ext
    LVL 23

    Expert Comment

    Try Class.forName() before setDataSource
    LVL 1

    Expert Comment

    Closed, 500 points refunded.
    Community Support Moderator

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
    Great sound, comfort and fit, excellent build quality, versatility, compatibility. These are just some of the many reasons for choosing a headset from Sennheiser.
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now