473,605 Members | 2,520 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Exception in thread "main" java.lang.nocla ssdeffound error

87 New Member
Hi

This is my codings in order to access mysql database from java.

Codings:

import java.sql.Connec tion;
import java.sql.Driver Manager;
import java.sql.Result Set;
import java.sql.Statem ent;

public class MysqlConnect {

public static void main(String[] args)throws Exception{
System.out.prin tln("MySQL Connect Example.");
Connection conn = null;
String url = "jdbc:mysql ://localhost:3309/";
String dbName = "ananthu";
String driver = "com.mysql.jdbc .Driver";
String userName = "root";
String password = "sa";
try {
Class.forName(d river);
conn = DriverManager.g etConnection(ur l+dbName,userNa me,password);
System.out.prin tln();
System.out.prin tln("Connected to the database");
System.out.prin tln();
Statement stmt = conn.createStat ement();
ResultSet reset = stmt.executeQue ry("select * from customer");
System.out.prin tln("Name\t\tAg e");
System.out.prin tln();
while(reset.nex t()){
//System.out.prin tln(reset.getSt ring(1));
//System.out.prin tln(reset.getSt ring(2));
System.out.prin tln(reset.getSt ring(1)+ "\t\t" + reset.getString (2));
}
conn.close();
System.out.prin tln();
System.out.prin tln("Disconnect ed from database");
} catch (java.lang.Clas sNotFoundExcept ion e) {
e.printStackTra ce();
}
}

}

I have mysqlconnector 5.0.7 jar file and i have placed it in program files folder.

The following is the execution of my codings.

Execution:

c:\program~1\ja va\jdk1.6.0_01\ bin>javac -classpath ";.\program files\mysql-connector-java-5.6.0_01" mysqlconnect

c:\progra~1\jav a\jdk1.6.0_01\b in>java -classpath ";.\program files\mysql-connector-java-5.6.0_01" mysqlconnect

Exception in thread "main" java.lang.nocla ssdeffound error: mysqlconnect

-----


The above error occurs only during running the program and not in compilation time.

How to rectify the error and run the program successfully?

Please help me...
Feb 16 '08 #1
3 6432
BigDaddyLH
1,216 Recognized Expert Top Contributor
Java is case sensitive, even under Windows, so be careful to write MySQLConnect, or whatever is the exact class name.
Feb 16 '08 #2
Ananthu
87 New Member
Hi

The same error occurs even when i give the class name in case sensitive manner also during execution.

Compilation is Successful but not running.

What to do?

Please give me the solution
Feb 17 '08 #3
BigDaddyLH
1,216 Recognized Expert Top Contributor
Are you including the current directory (".") in your list for classpath?
Feb 17 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
2990
by: Phillip Montgomery | last post by:
Hello all; I'm trying to debug an issue with a java script called, SelectSockets. It appears to be a fairly common one found on the web. I downloaded the SGI Java v1.4.1 installation from SGI's webpage and installed it using SGI's swmgr application. The installation was very straight forward and there were no errors when I installed the package. Then I ran /usr/java2/bin/javac SelectSockets.java to make the SelectSockets.class file.
1
9105
by: Andy Howells | last post by:
Can anybody help me on this? I am getting the below error but have not got a clue why. The file in my classpath eing used has the class that it says is not defined. Any ideas? I am running java version 1.4.0 and WMQ Series version 5.3 with CSD04. Exception in thread "main" java.lang.NoClassDefFoundError: com/ibm/mq/server/MQSESSION at com.ibm.mq.MQSESSIONServer.getMQSESSION(MQSESSIONServer.java:67) at...
12
7117
nomad
by: nomad | last post by:
Hi everyone; My Class has ended and I was not able to solve this problem in time, and I would still like to solve it. I got these error code. Exception in thread "main" java.lang.NullPointerException at ticketSales.TicketSales.makeEvent(TicketSales.java:185) at ticketSales.TicketInput.main(TicketInput.java:56) Anyway I have several Class This one is called TransAction
9
3112
by: jith87 | last post by:
What is ths error.????? I m nw loading the JDBC driver for connection with MySql. Exception in thread "main" java.lang.NoClassDefFoundError: MySQLJDBCDriverTest
9
3279
by: tiyaramunna | last post by:
I am trying to configure my system with Java program just to practice on the coding....when i compile a test.java program i am able to see the class file but i cant run the program ... I am getting the following error Exception in thread "main" java.lang.NoClassDefFoundError: test Caused by: java.lang.ClassNotFoundException: test at java.net.URLClassLoader$1.run(Unknown Source) at...
4
14715
by: jmitch89 | last post by:
I don't why I get this error: Exception in thread "main" java.lang.NoClassDefFoundError The statement below works just fine: java -cp "appframework-1.0.3.jar;swing-worker-1.1.jar";CurrentStrobe.jar com.visionpro.currentstrobe.CurrentStrobeApp However, the statement below produces the error: java -cp "appframework-1.0.3.jar;swing-worker-1.1.jar" -jar CurrentStrobe.jar Exception in thread "main"...
1
13717
by: jimgym1989 | last post by:
I dont get it..why is the error: Exception in thread "main" java.util.InputMismatchException this is my code /** * @(#)textFileRead.java * * * @author * @version 1.00 2008/10/17 */
3
7645
by: ohadr | last post by:
hi, i get Exception in thread "main" java.lang.NullPointerException when i run my application. the exact error is: "Exception in thread "main" java.lang.NullPointerException at sortmergejoin.MergeJoin.Field(MergeJoin.java:204) at sortmergejoin.MergeJoin.SMJoin(MergeJoin.java:84) at sortmergejoin.MergeJoin.<init>(MergeJoin.java:34) at sortmergejoin.Main.main(Main.java:24) Java Result: 1"
1
6748
by: onlinegear | last post by:
HI i am writing this for college i know i have loads of combo boxes with nothing in the i havent got that far yet. but every time i run this is comes up with this erro run: Exception in thread "main" java.lang.NullPointerException at java.awt.Container.addImpl(Container.java:1041) at java.awt.Container.add(Container.java:365) at orderingsystem.OrderingSystem.<init>(OrderingSystem.java:261) at...
0
7931
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8423
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8411
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8067
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8281
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5444
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3956
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2437
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1530
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.