User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 397,657 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,400 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 6571 | Replies: 7
Reply
Join Date: Apr 2007
Posts: 24
Reputation: ttamilvanan81 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
ttamilvanan81 ttamilvanan81 is offline Offline
Newbie Poster

JDBC Driver for SQL Server 2005, Class not found Exception

  #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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2004
Location: Netherlands
Posts: 5,660
Reputation: jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough 
Rep Power: 18
Solved Threads: 192
Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

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

  #2  
May 15th, 2007
have you actually added the required classes to your classpath when running your application?
42 Private messages asking for help will be ignored
In the frozen land of Nador they were forced to eat Steve's iMinstrels, and there was much rejoicing.
Reply With Quote  
Join Date: Apr 2007
Posts: 24
Reputation: ttamilvanan81 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
ttamilvanan81 ttamilvanan81 is offline Offline
Newbie Poster

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

  #3  
May 15th, 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 15th, 2007 at 11:48 pm.
Reply With Quote  
Join Date: Nov 2004
Location: Netherlands
Posts: 5,660
Reputation: jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough 
Rep Power: 18
Solved Threads: 192
Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

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

  #4  
May 16th, 2007
sounds like a bad jar file. Impossible to say which though (but most likely your own).
42 Private messages asking for help will be ignored
In the frozen land of Nador they were forced to eat Steve's iMinstrels, and there was much rejoicing.
Reply With Quote  
Join Date: Apr 2007
Posts: 24
Reputation: ttamilvanan81 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
ttamilvanan81 ttamilvanan81 is offline Offline
Newbie Poster

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

  #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  
Join Date: Dec 2004
Location: London or Slovakia
Posts: 2,183
Reputation: peter_budo has a spectacular aura about peter_budo has a spectacular aura about peter_budo has a spectacular aura about 
Rep Power: 10
Solved Threads: 265
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

  #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 3:29 am.
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

If we helped you to solve your problem, answered your question please mark your post as SOLVED.
Reply With Quote  
Join Date: Apr 2007
Posts: 24
Reputation: ttamilvanan81 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
ttamilvanan81 ttamilvanan81 is offline Offline
Newbie Poster

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

  #7  
May 23rd, 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  
Join Date: Feb 2008
Posts: 1
Reputation: sabindas is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
sabindas sabindas is offline Offline
Newbie Poster

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

  #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  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb Java Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the Java Forum

All times are GMT -4. The time now is 11:33 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC