Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-16-2008, 01:51 PM
Member
 
Join Date: May 2008
Posts: 9
rmaadil is on a distinguished road
Having problem in connecting with SQL Server 2005
I am using the following code for getting connection to the SQL Server 2005 Database:

Class.forName("com.microsoft.jdbc.sqlserver.SQLSer verDriver");

I have debuged the code by placing a breakpoint exactly at this line and whenever I step over this statement it generates an exception and then when I print the message in the catch block, I got the following message:

com.microsoft.jdbc.sqlserver.SQLServerDriver

which is exactly the string I am passing to the above function.

Can anybody help me?
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-18-2008, 09:27 AM
danielstoner's Avatar
Senior Member
 
Join Date: Apr 2008
Location: Canada
Posts: 183
danielstoner is on a distinguished road
what exception is that? Do you have the library in the path?
__________________
Daniel @ [
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
]
Language is froth on the surface of thought
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 05-19-2008, 08:32 AM
Member
 
Join Date: May 2008
Posts: 9
rmaadil is on a distinguished road
Can u explain me that how to include the library u r talking about. I am new to java so I don't have much knowledge about the language. Kindly elaborate.

I will be thankful to u.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 05-19-2008, 09:32 AM
Member
 
Join Date: May 2008
Posts: 9
rmaadil is on a distinguished road
Connecting To SQL Server
Here is the code that I have written to get a connection to the SQL Server. I have also set the classpath. But still I am getting error. I have debugged the code and when I step over the Class.forName("com.microsoft.jdbc.sqlserver.SQLSer verDriver"); it generates an exception and the message that is printed is the string that is the parameter to the function forName. I am struck as I have searched a lot of forums and I haven't found this kind of error. Most of the errors that came due to classpath settings was "drievr cannot be found" but I think my error is not because of the classpath settings. Can anyone help me?

public class Main {


public static void main(String[] args) {

try
{

Class.forName("com.microsoft.jdbc.sqlserver.SQLSer verDriver");
Connection con = DriverManager.getConnection("jdbc:microsoft:sqlser ver://localhost:1433; DATABASENAME = Test","mimdad","aaa");
}
catch (Exception e)
{
System.out.println(e.getMessage());
}

}
}
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 05-21-2008, 07:55 AM
danielstoner's Avatar
Senior Member
 
Join Date: Apr 2008
Location: Canada
Posts: 183
danielstoner is on a distinguished road
Did you notice you have a space in the name of the class?

"com.microsoft.jdbc.sqlserver.SQLSer verDriver" !!!

and also in the URL:

"jdbc:microsoft:sqlser ver://localhost:1433; DATABASENAME = Test"

Is that just a typo?

Read more about what should be in your classpath here: HOW TO: Get Started with Microsoft JDBC
__________________
Daniel @ [
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
]
Language is froth on the surface of thought
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
hibernate support for sql-server 2005 javadev Database 2 06-25-2008 02:48 PM
Connecting to a Web server Java Tip java.net 0 04-07-2008 08:57 PM
Java connecting to sql server 2005 pelegk2 Database 0 04-05-2008 10:17 PM
problem with viewing .java files when Visual J# 2005 Express Edition exist unhurt New To Java 3 11-03-2007 02:58 PM
SQL Server 2005 Jdbc connection mgt83 JavaServer Pages (JSP) and JSTL 0 07-27-2007 05:52 AM


All times are GMT +3. The time now is 01:07 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org