I'm fairly new to coding for database connections and running queries and all that. I've looked over some tutorials and examples and I feel like I've got 95% of this done correctly but there's gotta be something small I'm missing.
I'm currently trying to make a connection to a SQL Server database and I keep getting the exception:
This driver is not configured for integrated authentication.
Here is what my code looks like:
try {
String url = "jdbc:sqlserver://serverName;DatabaseName=database;integratedSecurity=true";
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection conn = DriverManager.getConnection(url, "username", "password");
Statement stmt = conn.createStatement();
ResultSet rs;
rs = stmt.executeQuery("select * from database.dbo.table\n" +
" where column = 2785 \n" +
" AND anotherColumn = 3");
while ( rs.next() ) {
String condition = rs.getString("Condition");
System.out.println(condition);
}
conn.close();
} catch (Exception e) {
System.err.println("Got an exception! ");
System.err.println(e.getMessage());
}
I think I'm running into an issue because our databases use Windows Auth. Here's what that looks like when I log into Microsoft SQL Server Management Studio:
What am I missing here?