Hi
i am trying Connect Java Application with Sql server database 2008(JDBC)
1) I created data base in sql server
create table Emp
(
Emp_id int not null primary key,
Emp_Name nvarchar(50),
Emp_Address nvarchar(50)
)
insert into Emp values(001,'xyz','BBSR')
insert into Emp values(002,'abc','CTC')
2)Taking one class and add the following code in eclipse IDE
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class Demo {
public static void main(String[] args) {
try{
Class.forName("com.microsoft.sqlserver.jdbc.SqlServerDriver");
Connection con=DriverManager.getConnection("jdbc:sqlserver://Servername;database=Employee;"+"IntegratedSecurity=true;");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("Select * from Emp");
while(rs.next())
System.out.println(rs.getInt(1)+ " "+rs.getString(2)+" "+rs.getString(3));
con.close();
}
catch(Exception e)
{
System.out.println(e);
}
but when i run this program in Eclipse following error was found "java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SqlServerDriver. So how to solve this, Please help
Note: i added Jar "sqljdbc4-2.0.Jar" in build path under library tab in Eclipse IDE. and using SQl Server 2008 management studio Express for creating a database.