Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-03-2007, 01:40 PM
Member
 
Join Date: Jun 2007
Posts: 6
Rep Power: 0
javagal is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 08-03-2007, 02:15 PM
levent
Guest
 
Posts: n/a
Default
Quote:
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).
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 08-04-2007, 01:36 PM
Member
 
Join Date: Jun 2007
Posts: 6
Rep Power: 0
javagal is on a distinguished road
Default
hay....thnx....
its solved..
I put Drivers jar file into java working directories lib file .

Its working file...
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
connecting to a database mxb7642 Database 5 09-08-2009 09:39 AM
Connecting to a database peiceonly New To Java 2 04-06-2008 03:28 PM
problem in connecting to mysql database nancyv Java Servlet 6 04-02-2008 12:33 PM
Specifying the character set while connecting to the database Java Tip Java Tips 0 02-13-2008 12:26 PM
Error while connecting to a database Fukushuusha Database 2 12-16-2007 10:40 AM


All times are GMT +2. The time now is 01:25 AM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org