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 November 11th, 2004, 11:21 PM
Authorized User
 
Join Date: Nov 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to pandjie
Default cannot make JSP-MySQL connection

I'am a newbie in JSP,& try to write the following program :

<%@ page language="java" import="java.sql.*" %>
<%
Class.forName("com.mysql.jdbc.Driver" ) ;// load ok
//these 2 lines is the problem, I think
Connection myConn=DriverManager.getConnection("jdbc:mysql//localhost/test","root","rahasia" ) ;
myConn.close();
%>
<html>
<head>
<title>membuat tabel dengan JSP</title>
</head>
<body>
Connection OK!..........
</body>
</html>

The Driver can be loaded, but if i add those 2 lines (Connection..... & myConn.........)
messages appear on the browser like this :

exception
javax.servlet.ServletException: No suitable driver
org.apache.jasper.runtime.PageContextImpl.doHandle PageException(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePa geException(PageContextImpl.java:758)
org.apache.jsp.database.btabel_jsp._jspService(bta bel_jsp.java:70)
org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet .java:802)

root cause
java.sql.SQLException: No suitable driver
java.sql.DriverManager.getConnection(DriverManager .java:532)
java.sql.DriverManager.getConnection(DriverManager .java:171)
org.apache.jsp.database.btabel_jsp._jspService(bta bel_jsp.java:47)
org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet .java:802)

What's wrong ? MySQL is up,and connection with PHP is OK!
I use Tomcat 5.0.27 + MySQL 4.0.18 in Linux Mdk + java version 1.4.2 + mysql-connector-java-3.0.14.


 
Old November 12th, 2004, 01:21 PM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 204
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello,


You seem to be missing a colon ":" try:

jdbc:mysql://localhost/test","root","rahasia

instead of

jdbc:mysql //localhost/test","root","rahasia






Similar Threads
Thread Thread Starter Forum Replies Last Post
WebShop : I cannot make remote connection JoinTTT BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 5 April 7th, 2007 04:33 PM
How to make a connection with access database arshad mahmood Classic ASP Professional 1 April 18th, 2006 03:53 AM
Can't make Connection Johnny6000 Classic ASP Databases 2 April 20th, 2005 04:32 AM
problem with JSP-MySQL connection pandjie Java Databases 2 November 18th, 2004 04:44 PM
Can't make PHP4 talk to MySQL adraffin PHP Databases 1 February 4th, 2004 10:00 PM





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