NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

Cannot connect to SQL server 2005

 
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users
View previous topic :: View next topic  
Author Message
holyjohn



Joined: 19 Apr 2010
Posts: 4
Location: Kuala Lumpur, Malaysia

PostPosted: Mon Apr 19, 2010 8:31 am    Post subject: Cannot connect to SQL server 2005 Reply with quote

I tried and search ways to connect SQL Server. But still getting ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver
error


This that I have done:
1. Downloaded Microsoft SQL Server 2005 JDBC Driver\sqljdbc_1.2.
2. Add environment variable
Name: CLASSPATH
Value: C:\Program Files\Microsoft SQL Server 2005 JDBC Driver\sqljdbc_1.2\enu\sqljdbc.jar
3. NetBean setting: Project Properties>Libraries
Added new JAR pointing to C:\Program Files\Microsoft SQL Server 2005 JDBC Driver\sqljdbc_1.2\enu\sqljdbc.jar

.java Code
-------------
import java.sql.*;
public class ConnectionTest1 {
public static void main(String [] args) {
Connection con = null;
try {

// Load Microsoft JDBC Driver 1.0
Class.forName(
"com.microsoft.sqlserver.jdbc.SQLServerDriver");
System.out.println("JDBC driver loaded ok.");

} catch (java.lang.ClassNotFoundException e) {
System.err.println("ClassNotFoundException: "
+e.getMessage());
}
}
}

Output
-------
ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver



DBconnection.java
 Description:

Download
 Filename:  DBconnection.java
 Filesize:  3.06 KB
 Downloaded:  186 Time(s)

Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo