Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java and SQLSERVER2008 connectivity

 
Bushra Fathima
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have the following code to connect to SQLSERVEer2008,

Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
connectionURl ---- jdbc:sqlserver://172.16.40.65:1433;DatabaseName=DBName,uname,pwd;

I am' using MYEclipse6.6 and have included sqljdbc4.jar in libraries.

But i 'am still getting No suitable driver error when i run application.


Can anyone help.

 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you include the jar file in the runtime classpath as well as the compile classpath?
 
Bushra Fathima
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I included the jar as usual we do in MyEclipse. right-click prj-> properties->Java Build path->Libraries. and then add external jars.

I have also set the jar in CLASSPATH in environment variables
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I included the jar as usual we do in MyEclipse. right-click prj-> properties->Java Build path->Libraries. and then add external jars.

That sounds like it's used at build time, not runtime.

I have also set the jar in CLASSPATH in environment variables

Are you running this within Eclipse? If so, then it's possible that CLASSPATH is not used.

Moving to the IDE forum.
 
Bushra Fathima
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So what is the solution now for me?please tell me what should be done.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18094
48
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The CLASSPATH for Eclipse isn't taken into consideration when debugging apps inside Eclipse. That's a completely different classpath, based on the project's classpath PLUS the debug session's classpath. You have left out some details, but from the sound of it, you're trying to debug and not getting the driver. You need to add the driver jar to the debug session's classpath. The Run/Debug Configurations menu will permit you to retrieve and edit the debugging profile, including its CLASSPATH.

Just for info, I was REALLY disappointed in the Microsoft SQL Server JDBC driver. I inherited a monstrosity where half the program's application logic was in stored procedures with transaction nesting all over the landscape. The Microsoft driver had a complete nervous breakdown. I switched to an open-source SQL Server driver I got from SourceForge and the problems went away.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic