Results 1 to 5 of 5
- 05-16-2008, 12:51 PM #1
Member
- Join Date
- May 2008
- Posts
- 9
- Rep Power
- 0
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?
- 05-18-2008, 08:27 AM #2
what exception is that? Do you have the library in the path?
Daniel @ [www.littletutorials.com]
Language is froth on the surface of thought
- 05-19-2008, 07:32 AM #3
Member
- Join Date
- May 2008
- Posts
- 9
- Rep Power
- 0
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.
- 05-19-2008, 08:32 AM #4
Member
- Join Date
- May 2008
- Posts
- 9
- Rep Power
- 0
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());
}
}
}
- 05-21-2008, 06:55 AM #5
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 JDBCDaniel @ [www.littletutorials.com]
Language is froth on the surface of thought
Similar Threads
-
hibernate support for sql-server 2005
By javadev in forum JDBCReplies: 2Last Post: 06-25-2008, 01:48 PM -
Connecting to a Web server
By Java Tip in forum java.netReplies: 0Last Post: 04-07-2008, 07:57 PM -
Java connecting to sql server 2005
By pelegk2 in forum JDBCReplies: 0Last Post: 04-05-2008, 09:17 PM -
problem with viewing .java files when Visual J# 2005 Express Edition exist
By unhurt in forum New To JavaReplies: 3Last Post: 11-03-2007, 01:58 PM -
SQL Server 2005 Jdbc connection
By mgt83 in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 07-27-2007, 04:52 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks