• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Trouble in retrieving data from the mysql database using JSTL

 
Greenhorn
Posts: 4
Netbeans IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am a newbie in using JSTL, so got stuck on a code where I need to retrieve the datas from a database without using any scripting code. I am using NetBEans IDE and mysql. I am using a user created database named as 'mydatabase' and a table named as 'events' which contains a column 'events' with lots of data in it.
So, the sql command Select events from mydatabase.events works fine.
A piece of my work goes below...is it made in an amaturish fashion?


Somehow, I keep receiving the exception message after the jsp page(sqlTest.jsp) is run.
The exception msg is:
javax.servlet.ServletException: javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: "java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/mydatabase"
and the root cause is:
javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: "java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/mydatabase"

However, I have imported the jar file MySQL JDBC Driver from the IDE's library to my project. The jar does contain the package com.mysql.jdbc with the Driver.class file. I also have the JSTL 1.1 and the standard.jar in my project. So everything is in place and I really dont know whats going wrong. The funny part is, the code works properly with the Derby database and its driver. So whats wrong with mysql's Driver???
 
Ranch Hand
Posts: 147
Eclipse IDE Tomcat Server Debian
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You mentioned importing the mysql driver into your project - is that driver also exported into your WAR file's WEB-INF/lib folder?
 
Sanjeev Das
Greenhorn
Posts: 4
Netbeans IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
thanks for the reply...appreciate that.
Oops, even by importing the mysql.jar into the WEB-INF/lib folder dsnt help...got the same exception.

 
Sanjeev Das
Greenhorn
Posts: 4
Netbeans IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any clues bout the issue... will b appreciated.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have the same problem.
i am using eclipse on ubuntu.
i did the same things but still error is there
any solution.?

My code

<%@ page language="java" import="java.lang.Class" %>
<%@ page language="java" import="java.sql.*" %>

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

<sql:setDataSource var="dataSource" driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/student" user="root" password="innovate" />
<html>
<head>
<title>Query Example</title>
</head>
<body>
<sql:query var="users" dataSource="$dataSource">
select * from personal;
</sql:query>
<table>
<c:forEach var="row" items="$users">
<tr>
<td><c:out value="$row.uname" /></td>
<td><c:out value="$row.fname" /></td>
<td><c:out value="$row.lname" /></td>
<td><c:out value="$row.city" /></td>
<td><c:out value="$row.mobile" /></td>
</tr>
</c:forEach>
</table>
</body>
</html>


I got the following errors:


javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: "java.sql.SQLException: No suitable driver found for $dataSource"
at org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.getConnection(QueryTagSupport.java:314)
at org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.doStartTag(QueryTagSupport.java:197)
at org.apache.taglibs.standard.tag.el.sql.QueryTag.doStartTag(QueryTag.java:123)
at org.apache.jsp.New_jsp._jspx_meth_sql_query_0(New_jsp.java from :140)
at org.apache.jsp.New_jsp._jspService(New_jsp.java from :82)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:109)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:406)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:483)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:373)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
at java.lang.Thread.run(Thread.java:662)
Selection_004.png
[Thumbnail for Selection_004.png]
Selection_005.png
[Thumbnail for Selection_005.png]
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try removing the dataSource="$dataSource" from the sql:query statement because, based on the error message, it appears that $datasource is not set. I don't think you need to specify a datasource for your sql statements if your code declares only one.
 
My cellmate was this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic