JDBC Driver for SQL Server 2005, Class not found Exception

Reply

Join Date: Apr 2007
Posts: 24
Reputation: ttamilvanan81 is an unknown quantity at this point 
Solved Threads: 0
ttamilvanan81 ttamilvanan81 is offline Offline
Newbie Poster

JDBC Driver for SQL Server 2005, Class not found Exception

 
0
  #1
May 15th, 2007
Hai, i am tried to use the SQL Server with Java and Tomcat 5.0 Application Server.
I am using the JDBC Driver for Java connecting with SQL Server. I m using SQL Server 2005. But the JDBC Connection doesn't create.
I have used the following code for java database connectivity with SQL Server

import java..sql.*;
public class Test {
public static void main(Sring[] args)
{
try
{
//load the driver class
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection conn = DriverManager.getConnection("jdbc:microsoft:sqlserver://127.0.0.1:1433; DatabaseName=timetracking ");
}
catch(ClassNotFoundException cnfe)
{
System.err.println(cnfe);
}
catch (SQLException sqle)
{
System.err.println(sqle);
}

The above code was compiled successfully, but it's not running. The below error was raised. I have coped and paste it the JDBC Driver class for SQL Server 2005(sqljdbc.jar) to theWEB-INF/lib folder.

java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver

I don't know what i am doing with wrong. If anybody know, how to solve this, kindly post me.

Thanks

Tamilvanan
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,144
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 212
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: JDBC Driver for SQL Server 2005, Class not found Exception

 
0
  #2
May 15th, 2007
have you actually added the required classes to your classpath when running your application?
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 24
Reputation: ttamilvanan81 is an unknown quantity at this point 
Solved Threads: 0
ttamilvanan81 ttamilvanan81 is offline Offline
Newbie Poster

Re: JDBC Driver for SQL Server 2005, Class not found Exception

 
0
  #3
May 16th, 2007
Originally Posted by jwenting View Post
have you actually added the required classes to your classpath when running your application?
Yes, i have put the corresponding class file to the path. when I tried to rectify this error another one error could be invoked, that error is...

May 16, 2007 9:13:23 AM java.util.jar.Attributes read
WARNING: Duplicate name in Manifest: Class-Path
May 16, 2007 9:13:23 AM java.util.jar.Attributes read
WARNING: Duplicate name in Manifest: Class-Path
May 16, 2007 9:13:23 AM java.util.jar.Attributes read
WARNING: Duplicate name in Manifest: Class-Path
May 16, 2007 9:13:23 AM java.util.jar.Attributes read
WARNING: Duplicate name in Manifest: Class-Path
May 16, 2007 9:13:23 AM java.util.jar.Attributes read
WARNING: Duplicate name in Manifest: Class-Path
May 16, 2007 9:13:23 AM java.util.jar.Attributes read
WARNING: Duplicate name in Manifest: Class-Path
May 16, 2007 9:13:23 AM java.util.jar.Attributes read
WARNING: Duplicate name in Manifest: Class-Path
May 16, 2007 9:13:23 AM java.util.jar.Attributes read
WARNING: Duplicate name in Manifest: Class-Path
May 16, 2007 9:13:23 AM java.util.jar.Attributes read
WARNING: Duplicate name in Manifest: Class-Path
May 16, 2007 9:13:23 AM java.util.jar.Attributes read
WARNING: Duplicate name in Manifest: Class-Path
May 16, 2007 9:13:23 AM java.util.jar.Attributes read
WARNING: Duplicate name in Manifest: Class-Path
May 16, 2007 9:13:23 AM java.util.jar.Attributes read
WARNING: Duplicate name in Manifest: Class-Path
May 16, 2007 9:13:24 AM java.util.jar.Attributes read
WARNING: Duplicate name in Manifest: Class-Path
May 16, 2007 9:13:24 AM java.util.jar.Attributes read
WARNING: Duplicate name in Manifest: Class-Path
java.sql.SQLException: No suitable driver


what's wrong with my same code, no changes made...

Thanks for your useful reply.


Tamilvanan
Last edited by ttamilvanan81; May 16th, 2007 at 12:48 am.
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,144
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 212
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: JDBC Driver for SQL Server 2005, Class not found Exception

 
0
  #4
May 16th, 2007
sounds like a bad jar file. Impossible to say which though (but most likely your own).
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 24
Reputation: ttamilvanan81 is an unknown quantity at this point 
Solved Threads: 0
ttamilvanan81 ttamilvanan81 is offline Offline
Newbie Poster

Re: JDBC Driver for SQL Server 2005, Class not found Exception

 
0
  #5
May 18th, 2007
Originally Posted by jwenting View Post
sounds like a bad jar file. Impossible to say which though (but most likely your own).
Hai,
Now its working fine, Thank you for all your replies.

Will meet you later.

Thanks & Regards

Tamilvanan
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,176
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 479
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: JDBC Driver for SQL Server 2005, Class not found Exception

 
0
  #6
May 18th, 2007
Would be nice if you tell us how you sorted, so people with similar problem can look at it
Last edited by peter_budo; May 18th, 2007 at 4:29 am.
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 24
Reputation: ttamilvanan81 is an unknown quantity at this point 
Solved Threads: 0
ttamilvanan81 ttamilvanan81 is offline Offline
Newbie Poster

Re: JDBC Driver for SQL Server 2005, Class not found Exception

 
1
  #7
May 24th, 2007
Originally Posted by peter_budo View Post
Would be nice if you tell us how you sorted, so people with similar problem can look at it
I had to do one settings in SQL Server Configuration Manager
Select Protocols for MSSQLSERVER under the SQL Server 2005 Network Configuration. Then Enable the TCP/IP Protocol.

And then i has to delete the old Driver(jar) file in the specified classpath, and then put the Driver File freshly.

Then i has been connected with SQL Server 2005.


Thanks

Tamilvanan
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 1
Reputation: sabindas is an unknown quantity at this point 
Solved Threads: 0
sabindas sabindas is offline Offline
Newbie Poster

Re: JDBC Driver for SQL Server 2005, Class not found Exception

 
0
  #8
Feb 7th, 2008
i am a fresher in java . i got the same error again and again ..
i set the class path like


set path="C:\Program Files\Microsoft SQL Server 2005 JDBC Driver\sqljdbc_1.0\enu\sqljdbc.jar";

also i made the changes in tcp/ip.

the code is compiling correctly. and when i am running its showing the raised exception
please help me ,

//////////////////////////////Code///////////////////////////
import java.sql.*;
import java.io.*;
public class db
{
/**/
static String username= "xxxxxx";
static String password= "xxxxxx";
static String thincon = "jdbc:freetds:sqlserver://local/JavaTest";
static String driverclass = "com.internetcds.jdbc.tds.Driver";
/**/
public static Connection GetConnection() throws SQLException
{
Connection cn = null;
try
{
Driver d = (Driver)Class.forName(driverclass).newInstance();
cn=DriverManager.getConnection(thincon,username,password);
return cn;
}
catch(Exception e)
{
e.printStackTrace(System.out);
throw new SQLException("Error loading JDBC Driver");
}
}

public static void main(String args[])
{
try
{
Connection conn = getConnection();
if(conn==null)
{
System.out.println("Connection is null");
System.exit(0);
}
else
{
boolean b = conn.getAutoCommit();
System.out.println("Connection ok");
System.out.println("AutoCommit"+b);

}
}
catch(SQLException e)
{
e.printStackTrace();

}
}
}
//////////////////////////////Exception/////////////////////

java db
Exception in thread "main" java.lang.NoClassDefFoundError: db
Caused by: java.lang.ClassNotFoundException: db
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
/////////////////////////////////////////////////////////////////////////

please help me for correcting this error . . .
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC