Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java Open Source > Apache Tomcat
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Apache Tomcat General discussion of the Apache Tomcat servlet container. For discussions specific to the Professional Apache Tomcat book, please see the book discussion forum for that book.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Apache Tomcat section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 12th, 2006, 12:44 PM
Registered User
 
Join Date: Nov 2005
Location: bhimavaram, Andhra Pradesh, India.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to balarkavelidi
Default Accessing MySql db from a Servlet(Urgent)

hi all,

Please help me in accessing Mysql database from a servlet.I configured mysql properly that i get no errors while running a normal java application.But when i access it using a servlet i get an exception:
com.mysql.jdbc.Driver:ClassNotFoundException.

here is the part of code:
//HAVE A LOOK AT THESE IMPORTS I AM NOT SURE WHETHER TO USE THEM IN TOMCAT.

import com.mysql.jdbc.Driver;
import com.mysql.jdbc.Statement;
import com.mysql.jdbc.Connection;
import com.mysql.jdbc.DocsConnectionPropsHelper;


public class xmlservlet extends HttpServlet
{
public Statement st1;
public Connection con;
public Document dom;
public int k=0;
public static String ipad="";
public Vector nod=new Vector();

public void doGet(HttpServletRequest req,HttpServletResponse res)
throws ServletException,IOException
{
PrintWriter out=res.getWriter();
res.setContentType("text/html");
    out.println("Welcome");

    String url="jdbc:mysql://localhost:3306/newdb?user=raju;password=ravi";
    try
    {
     Class.forName("[u]com.mysql.jdbc.Driver</u>");
     con=(Connection) DriverManager.getConnection(url,"raju","ravi");
     out.println("connected");
     st1 = (Statement) con.createStatement();
    }
    catch(Exception en)
     {
     en.printStackTrace();
     out.println("Exception: " + en.toString());
     }

Thanks in Advance.


vbalarka.
Reply With Quote
  #2 (permalink)  
Old January 15th, 2006, 10:03 AM
Authorized User
 
Join Date: Dec 2005
Location: , , .
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You should copy the driver of the mydql to the lib directory.


JAVA Email
http://www.wisesoft.biz/
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with updating the db using servlet Behl_Neha Java Databases 1 December 24th, 2007 06:08 AM
Can JSP integrate with Servlet and run on MySQL wesleygch JSP Basics 0 April 10th, 2007 02:22 AM
servlet accessing MySql ....error simplyAns MySQL 1 January 17th, 2006 03:41 AM
Accessing Java Servlet thru DotNet r_ganesh76 General .NET 0 June 23rd, 2004 11:45 PM



All times are GMT -4. The time now is 04:33 PM.


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