| | |
JDBC Driver for SQL Server 2005, Class not found Exception
![]() |
•
•
Join Date: Apr 2007
Posts: 24
Reputation:
Solved Threads: 0
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
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
•
•
Join Date: Apr 2007
Posts: 24
Reputation:
Solved Threads: 0
•
•
•
•
have you actually added the required classes to your classpath when running your application?
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.
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
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
•
•
Join Date: Apr 2007
Posts: 24
Reputation:
Solved Threads: 0
•
•
•
•
Would be nice if you tell us how you sorted, so people with similar problem can look at it
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
•
•
Join Date: Feb 2008
Posts: 1
Reputation:
Solved Threads: 0
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 . . .
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 . . .
![]() |
Similar Threads
- sql server 2005 express i need help<<<? (MS SQL)
- text message via sql server 2005 to mobile phone (MS SQL)
- How to connect queries from SQL Server 2005 to VB.Net Windows application (VB.NET)
- How to connect queries from SQL Server 2005 to VB.Net Windows application (MS SQL)
- Access & MS SQL Server 2005 (MS SQL)
- [For Hire] ASP.NET 2.0 (C#), Atlas, SQL Server 2005: Web Developer / Architect (Post your Resume)
Other Threads in the Java Forum
- Previous Thread: please help me debug this
- Next Thread: Primary key.
| Thread Tools | Search this Thread |
-xlint add android api applet application array arrays automation bi binary blackberry block bluetooth class client code compile compiler component database developmenthelp eclipse equation error event fractal freeze functiontesting game gameprogramming givemetehcodez graphics gui health html hyper ide idea image int integer j2me j2seprojects java javac javaprojects jetbrains jni jpanel jtable julia learningresources lego linux list login loops mac main map method methods mobile myregfun netbeans nonstatic notdisplaying number online pearl problem program project qt recursion scanner screen server set singleton sms sort spamblocker sql string swing system textfields thread threads time title tree tutorial-sample update variablebinding windows working xor






