aspose file tools*
The moose likes JDBC and the fly likes Class not found exception.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Class not found exception.." Watch "Class not found exception.." New topic

Class not found exception..

Nagendra Shasthri
Ranch Hand

Joined: Nov 12, 2010
Posts: 35

HI All,

I am connecting to MS SQL 2005 server using Java code..I have jtds.jar file..But still I am getting class not found exceptiion...Wat could be the reason?Please help me..I have deadline to submit.

With Regards,
Nagendra Shasthri
Ranch Hand

Joined: Nov 12, 2010
Posts: 35

This is my java code...

import java.sql.*;
import javax.sql.*;

public class JDBCDemo{

public static void main(String args[]){
String dbtime;

//String dbUrl = "jdbc:jtds:sqlserver://";
//String dbClass = "com.mysql.jdbc.Driver";
String query = "Select * FROM EMPLOYEE_MASTER where EM_ID=356";

try {
System.out.println("Hello....");.....................This line is printing..
System.out.println("Hi..");..............It will not be printed.
Connection con = DriverManager.getConnection("jdbc:jtds:sqlserver://ktwo-19:1433;DatabaseName=KHRMS","sa", "Welcome12");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(query);

while ( {
String s = rs.getString("EM_USERNAME");


catch(ClassNotFoundException e) {

catch(SQLException e) {

} //end main

} //end class
James Boswell

Joined: Nov 09, 2011
Posts: 973


It would be useful to see the stack trace of the exception. If nothing else, so we can see what class cannot be found.
Nam Ha Minh
Ranch Hand

Joined: Oct 31, 2011
Posts: 485

the class net.sourceforge.jtds.jdbc.Driver could not be found, although you have jtds.jar file. Make sure the jar file is present in the classpath.

PM Me If You Want to get Urgent Help on Java Programming
Nagendra Shasthri
Ranch Hand

Joined: Nov 12, 2010
Posts: 35

@James and Nam..Thank you guys for your time..Ya I didn't set the class path..That was the problem..Solved it..:-)
Rob Spoor

Joined: Oct 27, 2005
Posts: 19556

And could you please UseCodeTags next time? It will preserve whitespace and add syntax highlighting, making code easier to read.

How To Ask Questions How To Answer Questions
I agree. Here's the link:
subject: Class not found exception..
Similar Threads
Remote Interface
NEW SCEA Mock Test Available!!
NullPointerException in hibernate
custom class loader
Jasper Report and JAR file