This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Five Lines of Code and have Christian Clausen on-line!
See this thread for details.
Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

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

 
Ranch Hand
Posts: 34
  • 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);
}

}
}

 
author
Posts: 4173
29
jQuery Eclipse IDE Java
  • 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: 34
  • 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!
 
Marshal
Posts: 67417
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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.
 
Ranch Hand
Posts: 336
7
Tomcat Server Ubuntu Linux
  • 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.
 
Die Fledermaus does not fear such a tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic