•
•
•
•
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
![]() |
•
•
Join Date: Apr 2007
Posts: 24
Reputation:
Rep Power: 2
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: Nov 2004
Location: Netherlands
Posts: 5,660
Reputation:
Rep Power: 18
Solved Threads: 192
•
•
Join Date: Apr 2007
Posts: 24
Reputation:
Rep Power: 2
Solved Threads: 0
•
•
•
•
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.
•
•
Join Date: Nov 2004
Location: Netherlands
Posts: 5,660
Reputation:
Rep Power: 18
Solved Threads: 192
•
•
Join Date: Dec 2004
Location: London or Slovakia
Posts: 2,183
Reputation:
Rep Power: 10
Solved Threads: 265
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.
Publilius Syrus
(~100 BC)
If we helped you to solve your problem, answered your question please mark your post as SOLVED.
•
•
Join Date: Apr 2007
Posts: 24
Reputation:
Rep Power: 2
Solved Threads: 0
•
•
•
•
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
•
•
Join Date: Feb 2008
Posts: 1
Reputation:
Rep Power: 0
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 . . .
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb Java Marketplace
•
•
•
•
ad advertising ajax architecture asp backup beta business centro com crash daniweb database dell developer development enterprise google hacker internet java linux longhorn mail microsoft microsoft sdk for java microsystems msdn news novell office open platform programming qmail red hat rhel security server smtp software source sql sun survey suse vista web windows windows server
- 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.



Linear Mode