Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Other Java > Java Databases
|
Java Databases Discussion specific to working with Java Databases. For other Java topics, please see related Java forums. For database discussions not specific to Java, please see the Database category.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java Databases 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:31 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 problem with JSP-MySQL connection

Hi,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 17th, 2004, 03:16 AM
Authorized User
 
Join Date: Aug 2004
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to olupas
Default

Hi

Try using the Database port 3306 (which is the defaul one) in URL

Hope it works

 
Old November 18th, 2004, 04:44 PM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 204
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try adding a colon ":" in the following line

Connection myConn=DriverManager.getConnection("jdbc:mysql://localhost/test","root","rahasia" ) ;

You missed it -

("jdbc:mysql !! //localhost/test","root","rahasia" )







Similar Threads
Thread Thread Starter Forum Replies Last Post
MySQL Connection Problem! Doug86 Dreamweaver (all versions) 3 March 30th, 2008 11:15 AM
PHP5 connection problem with MYSQL Calverstine PHP Databases 3 August 31st, 2005 01:27 AM
PHP5 connection problem with MYSQL Calverstine PHP How-To 0 August 22nd, 2005 05:09 AM
cannot make JSP-MySQL connection pandjie JSP Basics 1 November 12th, 2004 01:21 PM





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