Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > JSP Basics
JSP Basics Beginning-level questions on JSP. More advanced coders should post to Pro JSP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the JSP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old January 31st, 2004, 02:02 PM
Registered User
Join Date: Jan 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Can't connect to MySQL using JSTL tag

I am trying to display data using JSTL SQL tags as instructed on page 91 (Beginning JSP 2.0), and I got the following error message :
javax.servlet.ServletException: Unable to get connection, DataSource invalid: "java.sql.SQLException: Invalid authorization specification,  message from server: "Access denied for user: 'gabriel@localhost.localdomain' (Using password: YES)""

Below is my source code :

<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql_rt" %>

<sql:setDataSource var="datasource"
                  user="gabriel" password="xxx" />

<sql:query var="books" dataSource="${datasource}">
    SELECT id, title, price FROM book

        <title>A First JSP Database</title>
        <table border="1">
            <c:forEach items="${book.rows}" var="row">
                <td><c:out value="${row.id}" /></td>
                <td><c:out value="${row.title}" /></td>
                <td><c:out value="${row.price}" /></td>
I have granted all privilege to "gabriel" user in mysql by:
mysql> use ebusiness
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> grant all privileges on ebusiness to gabriel@localhost.localdomain identified by 'xxx';
Query OK, 0 rows affected (0.11 sec)
Please help....

Old January 31st, 2004, 03:04 PM
Friend of Wrox
Join Date: Jun 2003
Posts: 175
Thanks: 0
Thanked 0 Times in 0 Posts

Try using the IP address instead of the host name. e.g. instead of localhost.


Old January 31st, 2004, 04:01 PM
Registered User
Join Date: Jan 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts

I changed the hostname with the IP address but still having the same error message.

Old January 31st, 2004, 05:04 PM
Registered User
Join Date: Jan 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts

I finally got it to work. :-)

In my /etc/hosts file, I have this configuration :
Code:    localhost.localdomain    localhost
Although in the JSTL tag, I put :
Somehow, the JSTL tried to connect to user gabriel@localhost.localdomain that does not exist in mysql.
So I created a new user gabriel@localhost.localdomain, and everything works just fine... :-)

Thanks for your help, Martyn...

Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable connect to MySQL using JSTL tag PatrickWalsh JSP Basics 12 December 15th, 2004 01:41 PM
Trying to connect to Mysql tp194 Classic ASP Databases 4 November 11th, 2004 12:12 AM
Best way to connect to mySQL netdaviso Java Databases 1 April 5th, 2004 06:37 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.