Getting error java.lang.ClassNotFoundException: com.mysql.jdbc.Driver.

Getting error java.lang.ClassNotFoundException: com.mysql.jdbc.Driver.

I am doing project in JSP with database WampServer and glassfish as server .when i done database connection then i get an error java.lang.ClassNotFoundException: com.mysql.jdbc.Driver. The following is the code of connection. Please suggest the solution or give sample code of mysql connection. Your inputs are very valuable to me.

<%@ page import="java.sql.*" %> <%@ page import="java.io.*" %>

Connection with mysql database

Connection status

<% try { /* Create string of connection url within specified format with machine name, port number and database name. Here machine name id localhost and database name is usermaster. */ String connectionURL = "jdbc:mysql://shree:8080/tickettool";

// declare a connection by using Connection interface Connection connection = null;

// Load JBBC driver "com.mysql.jdbc.Driver" Class.forName("com.mysql.jdbc.Driver" + "").newInstance();

/* Create a connection by using getConnection() method that takes parameters of string type connection url, user name and password to connect to database. */ connection = DriverManager.getConnection(connectionURL,"","");

// check weather connection is established or not by isClosed() method if(!connection.isClosed()) %>

<% out.println("Successfully connected to " + "MySQL server using TCP/IP..."); connection.close(); } catch(Exception ex){ %> <% out.println("Unable to connect to database."+ex); } %>

View Answers

November 26, 2010 at 11:36 AM

Hi Friend,

Do you have mysql-connector-java-5.0.5.jar file inside the lib folder of web server?

Have you set the class path?

Check it...........

Thanks









Related Tutorials/Questions & Answers:
Getting an error :(
Getting an error :(  I implemented the same code as above.. But getting this error in console... Console Oct 5, 2012 10:18:14 AM org.apache.tomcat.util.digester.SetPropertiesRule begin WARNING: [SetPropertiesRule]{Server
Getting Error - Development process
Getting Error   Hi , i am getting error while executing this code. I just want to store date in to database. Dont mistake me for repeated questions. java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Number
Advertisements
Getting error java.lang.ClassNotFoundException: com.mysql.jdbc.Driver.
Getting error java.lang.ClassNotFoundException: com.mysql.jdbc.Driver. ... .when i done database connection then i get an error java.lang.ClassNotFoundException: com.mysql.jdbc.Driver. The following is the code of connection. Please
getting an error when set classpath
getting an error when set classpath  Hello Everyone! i have used hssf model for reading excel sheet in my project & i have set classpath... run it, it gives an error "could not find or load main" please help me
data type used to store name.(getting an error)
data type used to store name.(getting an error)    Statement stm=con.createStatement(); String query="select * from employee where ename... getting an error like dis: "ename cannot be resolved to a variable" whats
getting error in your login form code
getting error in your login form code  i tried your code for login form but i am getting an error.the error is undefined index userid and password.the code is $fuser=$POST["userid"];. how to solve this problem please help me
Getting connect error in Jmeter - Development process
Getting connect error in Jmeter  Hi, Am trying to run a simple application in Jakarta Jmeter using HTTP request sampler. I am getting the below error. Please help me in viewing the results. Pl specify if there is any possible
Im getting this error while running JPA project
Im getting this error while running JPA project  Exception in thread "main" javax.persistence.PersistenceException: [PersistenceUnit: examplePersistenceUnit] Unable to configure EntityManagerFactory
Still getting the http 404 error - Java Beginners
Still getting the http 404 error  Dear experts, I refer to the last solution given to me. A few clarification:- 1. I must stress... is userid? Anyway, whatever I do, I still receive the http 404 error...saying
getting error while inserting values in database
getting error while inserting values in database  AddUser.java..."); if (envContext == null)throw new Exception("Error: No Context"); if (ds == null) throw new Exception("Error: No DataSource
Getting File path error - JSP-Servlet
Getting File path error  I have a requirement where i need to get certain properties on application login page start itself. I an currently using String str = request.getRealPath("/")+"a" + System.getProperty( "file.separator
why i'm getting this error?The import javax.servlet.http cannot be resolved
why i'm getting this error?The import javax.servlet.http cannot... getting this error, why i'm getting this error and how to solve this error., Have...-quick-tip-resolving-error-the-import-javaxservlet-cannot-be-resolved/ ** any
Getting HTTP 404 error in Spring web MVC with Hibernate Integration
Getting HTTP 404 error in Spring web MVC with Hibernate Integration   Hi, i am Getting HTTP 404 error in Spring web MVC with Hibernate Integration after click on submit button. so provide me a better solution.   
i am getting an error in adding a menu item to a menu.
i am getting an error in adding a menu item to a menu.   i am not able to execute the menu program. i am getting an error at menu.add(menuitem); it says add method is undefined for type menu. but as far as i know that is only way
error getting repository data for epel repository not found centos 7
error getting repository data for epel repository not found centos 7  ... because of the error: error getting repository data for epel repository not found My os is centos 7. How to resolve this? Thanks   Hi, This error
error getting repository data for epel repository not found centos 7
error getting repository data for epel repository not found centos 7  ... because of the error: error getting repository data for epel repository not found My os is centos 7. How to resolve this? Thanks   Hi, This error
error for getting the data from an api using br.readLine - Development process
error for getting the data from an api using br.readLine  hi the application is hanging while reading the data using readLine() function . actually the data is coming from remote using particular api call see the following code
getting following error org.hibernate.AnnotationException: No identifier specified for entity: inheritance_tutorial17.TwoWheeler
getting following error org.hibernate.AnnotationException: No identifier specified for entity: inheritance_tutorial17.TwoWheeler  when i am running following code i am getting following error... package inheritance_tutorial17
Itried all possible ways still getting thesame error
Itried all possible ways still getting thesame error  java.sql.SQLException: Io exception: Got minus one from a read call at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112
I am getting error org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'IS_AUTHENTICATED_ANONYMOUSLY' is defined - Spring
I am getting error org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'IS_AUTHENTICATED_ANONYMOUSLY' is defined  Hello, I am getting error
when sending the mail from java I am getting the below error - JavaMail
when sending the mail from java I am getting the below error   when sending the mail from java I am getting the below error : Exception in thread "main" java.lang.NoClassDefFoundError: javax.mail.internet.MimeMessage
error
error  while iam compiling iam getting expected error
I'm getting an illgal start of expression error in my code for the public static boolean portion at the bottom... any ideas?
I'm getting an illgal start of expression error in my code for the public static boolean portion at the bottom... any ideas?  heres my code import java.util.Scanner; import java.util.Random; public class numberGame
Error-
Error-   Hello, I would like to know about XSD file. I try to print XML file but I am getting error SAXException-- says Content is not allowed in prolog. Please help me
error
/ServletUserEnquiryForm.shtml getting an error given below SQLException caught: [Microsoft][ODBC SQL Server Driver]COUNT field incorrect or syntax error please suggest
error
"+it); } } this is my program i am getting an error saying cannot find symbol class stringADS
Error
Error  Hi. I am getting error in the following code after the line I have commented as ERROR. How to solve this. Thanks in advance. package...;"); // ERROR out.println(" var pattern
Error
Error  Hi. I am getting error in the following code after the line I have commented as ERROR. How to solve this. Thanks in advance. package...;"); // ERROR out.println(" var pattern
Error
Error  Hi. I am getting error in the following code after the line I have commented as ERROR. How to solve this. Thanks in advance. package...;"); // ERROR out.println(" var pattern = /^\d{3,5
Error
Error  Hi. I am getting error in the following code after the line I have commented as ERROR. How to solve this. Thanks in advance. package...;"); // ERROR out.println(" var pattern
error
error  i have 404 error in my program plz tell me yhe solution about
error
error  i have 404 error in my program plz tell me yhe solution about
Error
Error  I have created ajax with php for state and city. When I change state then city will not come in dropdown list and it give me error as 'Unknown Runtime Error'. This error come only in IE browser, but in other brower
error
error  java.lang.unsupportedclassversionerror:bad major version at offset 6 how to solve this????   Hi, Please check the version of framework used and also the JDK version.ADS_TO_REPLACE_1 This type error also comes
error
error
error
error  When I deploye the example I have this message cannot Deploy HelloWorld Deployment Error for module: HelloWorld: Error occurred during deployment: Exception while deploying the app [HelloWorld
error!!!!!!!!!
error!!!!!!!!!   st=con.createStatement(); int a=Integer.parseInt(txttrno.getText()); String b=txttname.getText(); String c=txtfrom.getText(); String d=txtto.getText
error!!!!!!!!!
error!!!!!!!!!   st=con.createStatement(); int a=Integer.parseInt(txttrno.getText()); String b=txttname.getText(); String c=txtfrom.getText(); String d=txtto.getText
error!!!!!!!!!
error!!!!!!!!!   st=con.createStatement(); int a=Integer.parseInt(txttrno.getText()); String b=txttname.getText(); String c=txtfrom.getText(); String d=txtto.getText
error
error  whats the error.............. import java.util.Scanner; public class g { public static void main(String[] args) { Scanner s=new Scanner(System.in); int d,x,y; System.out.println("Enter the first number
Getting Exception
Getting Exception  How to get exception from commented code in java
getting variables
getting variables   how to get variables from servlet program to webservice program
getting the emplo
getting the emplo   I have one table "EMPLOYEEMASTER" contains 'emp id', 'employee name' for eg: emp id employee name... kumar i want the sql statement for getting like
Getting NumberFormatException
Getting NumberFormatException  Thanks for the reply. Its works well, but whenever I'm using numeric value from 0010 to 0757 it is returning some garbage value. I dont have the idea what is going wrong. Please give me some idea
Getting NumberFormatException
Getting NumberFormatException  Hello Sir, I'm using Integer.parseInt(String str) function which returns a NumberFormatException(Unknown source). I also used Integer.parseInt(String str, int radix) but it also throws the exception
getting errors
getting errors  public class positive { public static void main(String[] args) { retainPositiveNumbers(a); } private static int n; private static int j; static int a[]={-1,2,3,4,-5}; static int
getting voucherPin
getting voucherPin  I am doin an online credit topup application..and i need a method to fetch and decrypt the voucherpin from Database.. this is my voucher repository Class. public interface VoucherRepository extends
Getting exception in hello world
Getting exception in hello world  I run your hibernate5 "hello world" program. But, getting an exception: ERROR: Table 'mydb.employee' doesn't exist Exception in thread "main" javax.persistence.PersistenceException
Getting exception in hello world
Getting exception in hello world  I run your hibernate5 "hello world" program. But, getting an exception: ERROR: Table 'mydb.employee' doesn't exist Exception in thread "main" javax.persistence.PersistenceException
problem getting password - JavaMail
problem getting password  hi i am trying to get password but igot following error Error sending mail:javax.mail.MessagingException: Could not connect to SMTP host: 192.168.10.14, port: 25;nested exception

Ads