Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JSP-Servlet Getting error java.lang.ClassNotFoundException: com.mysql.jdbc.Driver.
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Ganesh D Ganbote
Getting error java.lang.ClassNotFoundException: com.mysql.jdbc.Driver.
1 Answer(s)      3 years and 10 months ago
Posted in : JSP-Servlet


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); } %>


Advertisement
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
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
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 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
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
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.   
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
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  while iam compiling iam getting expected error
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
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 emp id
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
error
"+it); } } this is my program i am getting an error saying cannot find symbol class string
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
Advertisements
 

 

 

DMCA.com