Hello,
I'm trying to display a table from sql server with local connection(everything is in my computer). I'm using netbeans, apache
tomcat as a service, sql server express 2008(using windows authentication) and I have the following code:
<%@ page language="java" import="java.sql.*"%>
<head>
<title> Northwind: JSP and SQLServer 2005 </title>
</head>
<body bgcolor>
<%
try
{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
}
catch (ClassNotFoundException e)
{
out.println("<h1>Driver not found:" + e + e.getMessage()+ "</h1>" );
}
try
{
Connection conn = DriverManager.getConnection("jdbc:sqlserver://MICHAEL-PC\\SQLEXPRESS:1433;database=Northwind;Integrated Security=True");
Statement stmt = conn.createStatement();
ResultSet rs;
rs = stmt.executeQuery("SELECT * FROM Employees");
out.println( "<table>" );
while ( rs.next() )
{
String id = rs.getString("EmployeeID");
String ln = rs.getString("LastName");
String fn = rs.getString("FirstName");
String ti = rs.getString("Title");
out.println("<tr><td>"+id+"</td><td>"+ln+"</td><td>"+fn+"</td><td>"+ti+"</td>");
}
out.println( "</table>" );
conn.close();
} catch (Exception e)
{
out.println( "<h2>Exception: "+e.getMessage()+"</h2>" );
}
%>
</body>
</html>
After 3 or 4 exceptions I copied the sqljdbc4.jar in "C:\Users\Michael\Documents\NetBeansProjects\TestJDBC\build\web\WEB-INF\lib" folder,
I changed the TCP Port to 1433 (through configuration manager>Network configuration>Protocols for SQLExpress>TCP/IP>IPAll),
also tried to include to the library of the web project the sqljdbc4.jar but still no go.
I'm also using the odbc-jdbc bridge for the connection.
So, the latest error i'm getting when trying to run the project is: Exception: Login failed for user ''.
I've read solutions from others and the were saying to change the server authentication from windows authentication to sql server and windows authentication mode but it didn't work with me.
Please any suggestions would be more than helpful.
Thank you in advance.