I have try everything to retrieve data using
JDBC from SQL data base, i have downloaded the JDBC Driver and i install it properly , but the initialization seem to be the problem because I'M using window authentication to sign in my SQL server and every tutorial i watch use Password and Username, when ever i call my application this way it return ClassNotFoundExceptional error:
import java.sql.*;
//import com.microsoft.sqlserver.jdbc.SQLServerCallableStatement;
public class SimpleJDBC
{
public static void main(
String[] args)
{
try
{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
//Connection conn = DriverManager.getConnection("jdbc:microsoft:sqlserver://ADEBIADE:1433");
String connectionUrl = "jdbc:sqlserver://localhost:1433;"+"database=TimeCards;integratedSecurity=true;";
Connection conn = DriverManager.getConnection(connectionUrl);
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery("select distinct FirstName from TimeCards.dbo.Employee(HumanResources)");
while(rs.next())
{
System.out.println(rs.getString(1) );
}
st.close();
//System.out.println(conn.getMetaData().getDatabaseProductName);
conn.close();
}
catch(ClassNotFoundException xp)
{
System.out.println("The ClassNotFoundException exception has Occured"+xp);
}
catch(SQLException xcp)
{
System.out.println("The SQLException exception has occured:"+xcp);
}
}
}