• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can you explain JDBC with window authentication SQL without using Password and username?

 
Agunbiade Ademola
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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);
}

}
}

 
Scott Selikoff
author
Saloon Keeper
Posts: 4033
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't recommend Windows-based authentication for JDBC application. It's extremely non-standard and proprietary and will make your application difficult to use with other databases or environments. Create a username/password on the SQL Server.
 
Agunbiade Ademola
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your respond so far everything have been working for me but i always get stock when it get to SQL, so i decided to uninstall my sql server i had on my system and to retsart it again so that i can simply make the username and password authentication with the JDBC, i have the JDBC 4 driver in my Program File already.

Kindly lead to where i can get the full Microsoft SQL server soft download on internet if can help. i prefer the enterprise edition while I'm using window 8 with Sony vaio Laptop, very important to me kindly help me!
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65342
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A quick google revealed that you can download the free trial for SQL Server from here. After 180 days you will need to buy a license.
 
margaret gillon
Ranch Hand
Posts: 335
6
Linux Tomcat Server Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can download SQLserver Express with Tools from here SQLserver Express. It is not a trial version but a full working version of SQLserver. The SQLServer Express has processor and data limits but they should be adequate for development and for small applications.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic