Hi,

You must add sql server jdbc jar file to classpath(your java
home/jre/lib/ext).Also you must set your sqlserver config.(in configuration
manager,set connection port as 1433).And you must specify a username and
password.And try it again.if you get en exception again,write again.


import java.sql.*;
public class JDBCDemo {
//    private Connection con;
    public static void main(String[] str){
         new JDBCDemo().connect();
    }
    private void connect(){
        try{
        Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");

        String connectionUrl =
"jdbc:sqlserver://localhost:1433;database=AdventureWorks;integratedSecurity=true;";
        Connection con =
DriverManager.getConnection(connectionUrl,"username","password");

        System.out.println("Connection Established");
        }catch(Exception e){
            e.printStackTrace();
        }
    }
}

2009/12/25 bijesh shyanth <shyanth_1...@yahoo.co.in>

>   Hi
>
> I was just trying to run this program
>
> import java.sql.*;
> public class JDBCDemo {
> //    private Connection con;
>     public static void main(String[] str){
>          new JDBCDemo().connect();
>     }
>     private void connect(){
>         try{
>         Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
>         String connectionUrl =
> "jdbc:sqlserver://localhost;database=AdventureWorks;integratedSecurity=true;";
>         Connection con = DriverManager.getConnection(connectionUrl);
>         System.out.println("Connection Established");
>         }catch(Exception e){
>             e.printStackTrace();
>         }
>     }
> }
>
> and i got exception
>
> 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.java:188)
>         at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
>         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
>         at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
>         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
>         at java.lang.Class.forName0(Native Method)
>         at java.lang.Class.forName(Class.java:169)
>         at Chapter1.JDBCDemo.connect(JDBCDemo.java:20)
>         at Chapter1.JDBCDemo.main(JDBCDemo.java:16)
>
>
>
> Can anyone out there please help me what should i do am new to JDBC
> programming
>
>
> Thanks in advance
>
> Bijesh
>
> ------------------------------
> The INTERNET now has a personality. YOURS! See your Yahoo! 
> Homepage<http://in.rd.yahoo.com/tagline_yyi_1/*http://in.yahoo.com/>.
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Java EE (J2EE) Programming with Passion!" group.
> To post to this group, send email to
> java-ee-j2ee-programming-with-passion@googlegroups.com
> To unsubscribe from this group, send email to
> java-ee-j2ee-programming-with-passion+unsubscr...@googlegroups.com<java-ee-j2ee-programming-with-passion%2bunsubscr...@googlegroups.com>
> For more options, visit this group at
>
> http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en?hl=en




-- 


Ali Ekber ÇELİK
+905556129172

-- 
You received this message because you are subscribed to the Google
Groups "Java EE (J2EE) Programming with Passion!" group.
To post to this group, send email to
java-ee-j2ee-programming-with-passion@googlegroups.com
To unsubscribe from this group, send email to
java-ee-j2ee-programming-with-passion+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en?hl=en

Reply via email to