Results 1 to 2 of 2

Thread: Exception

  1. #1
    rmaadil is offline Member
    Join Date
    May 2008
    Posts
    9
    Rep Power
    0

    Default 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.

  2. #2
    felixtfelix is offline Member
    Join Date
    Dec 2007
    Location
    Mumbai, India
    Posts
    37
    Rep Power
    0

    Default

    hi,

    It is clear that you dont have the sqljdbc.jar in your class path. This is the jar file which supports the JDBC 3 Driver to connect with Database.

    Regards

    Felix T

Similar Threads

  1. Need help on Exception
    By Deon in forum New To Java
    Replies: 7
    Last Post: 02-11-2010, 05:46 PM
  2. Exception!
    By rameshraj in forum Advanced Java
    Replies: 1
    Last Post: 05-05-2008, 01:39 PM
  3. exception
    By Oktam in forum New To Java
    Replies: 2
    Last Post: 03-23-2008, 07:01 PM
  4. Replies: 1
    Last Post: 03-08-2008, 06:41 PM
  5. Exception
    By Camden in forum New To Java
    Replies: 2
    Last Post: 11-26-2007, 11:50 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •