Click here to Skip to main content
15,885,915 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have created a program by which we can save the data into the database.front end is java swing and i am using jdk1.5.0 and back end is mysql the problem is that i not able to save the record and its showing
Java.Lang.ClassNotFoundExeption:com.mysql.jdbc.Driver
and source code is:
Java
try{
	Connection con = null;
	Class.forName("com.mysql.jdbc.Driver");
	con = DriverManager.getConnection("jdbc:mysql://localhost:3306/azim", "root", "apnaghar");
	Statement st = con.createStatement();
	int i= st.executeUpdate("Insert into meical(itemCode,itemName,catagory,type,suppliyer,expDate,manDate,MRP,position) values('"+t1.getText()+"','"+t2.getText()+"','"+lb1.getSelectedItem()+"','"+lb2.getSelectedItem()+"','"+t3.getText()+"','"+t4.getText()+"','"+t5.getText()+"','"+t6.getText()+"','"+t7.getText()+"')");
	JOptionPane.showMessageDialog(null,"Data is successfully inserted into the database." );
	st.close();
	con.close();
	}
	catch(Exception e)
	{
	System.out.println(e);
	}
	
	}
Posted
Updated 21-Mar-12 1:33am
v2

The part of code on
Class.forName("com.mysql.jdbc.Driver")

could not find the jdbc driver.
Download it from Download Connector/J[^]
Read this to setup JDBC - Environment[^]
 
Share this answer
 
v2
you don't have "com.mysql.jdbc.Driver" ,please update it ,it will work..
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900