Results 1 to 3 of 3
  1. #1
    javagal is offline Member
    Join Date
    Jun 2007
    Posts
    6
    Rep Power
    0

    Default connecting to mysql database

    Hi,
    I have written a simple jsp file in netbeans 5.0, which connects to mysql database.
    I am using a Connector/J driver,

    This is my code :

    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@page import="java.sql.Connection,
    java.sql.DriverManager,
    java.sql.SQLException"
    %>
    <%

    Connection con = null;
    out.println("coming here...");
    try
    {
    Class.forName("com.mysql.jdbc.Driver").newInstance ();
    con = DriverManager.getConnection("jdbc:mysql:///ebusiness","root", "nbuser");
    if(!con.isClosed())
    {
    out.println("Successfully connected to " +"MySQL server using TCP/IP...");
    }
    }catch(SQLException e) {
    e.printStackTrace();
    }
    catch(Exception ex) {
    out.println("Exception: " + ex.getMessage());
    } finally
    {
    try
    {
    if(con != null)
    con.close();
    } catch(SQLException e) {
    out.println("Exception: " + e.getMessage());
    }
    }


    %>


    when i run this program,
    I m getting exception as : Exception: com.mysql.jdbc.Driver

    while I have installed mysql driver on my machine.., but do i need to keep my Driver class file at any perticular location/

    Please help me.

  2. #2
    levent Guest

    Default

    I m getting exception as : Exception: com.mysql.jdbc.Driver
    I guess this is not the full exception. There should be some notes/description related to this (e.g. could not find xxxx).

  3. #3
    javagal is offline Member
    Join Date
    Jun 2007
    Posts
    6
    Rep Power
    0

    Default

    hay....thnx....
    its solved..
    I put Drivers jar file into java working directories lib file .

    Its working file...

Similar Threads

  1. connecting to a database
    By mxb7642 in forum JDBC
    Replies: 5
    Last Post: 09-08-2009, 08:39 AM
  2. Connecting to a database
    By peiceonly in forum New To Java
    Replies: 2
    Last Post: 04-06-2008, 02:28 PM
  3. problem in connecting to mysql database
    By nancyv in forum Java Servlet
    Replies: 6
    Last Post: 04-02-2008, 11:33 AM
  4. Replies: 0
    Last Post: 02-13-2008, 11:26 AM
  5. Error while connecting to a database
    By Fukushuusha in forum JDBC
    Replies: 2
    Last Post: 12-16-2007, 09:40 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •