Thread: Exception
View Single Post
  #1 (permalink)  
Old 05-19-2008, 11:52 AM
rmaadil rmaadil is offline
Member
 
Join Date: May 2008
Posts: 9
rmaadil is on a distinguished road
Exception
Following is the code that I have written to get connection to SQL Server:


public class Main {


public static void main(String[] args) {

try
{

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

}
}



and following is the exception that I am getting at the Class.forName().


java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver
at java.net.URLClassLoader$1.run(URLClassLoader.java: 200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.j ava:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:3 06)
at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:2 51)
at java.lang.ClassLoader.loadClassInternal(ClassLoade r.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at sqlserver.Main.main(Main.java:39)


Can anybody help me.
Reply With Quote
Sponsored Links