JSP tutorial connecting SQL Server 2005 with connection failure resolution
<%
Statement St=null;
Class.forName ("Com.microsoft.sqlserver.jdbc.sqlserverdriver");
Connection con=drivermanager.getconnection ("Jdbc:sqlserver://localhost:1433;databasename=acmen", "sa", "");
St=con.createstatement (resultset.type_scroll_sensitive,resultset.concur_read_only);
ResultSet rs=st.executequery ("select * from Stu_1");
while (Rs.next ()) {
%>
<%=rs.getstring ("userid")%>
<%
21}
%>
If the connection fails, try the following workaround
First download
Microsoft SQL Server Driver JDBC 1.2
ASP Tutorial X?FAMILYID=C47053EB-3B64-4794-950D-81E1EC91C1BA&DISPLAYLANG=ZH-CN ">http://www.microsoft.com/ Downloads/details.aspx?familyid=c47053eb-3b64-4794-950d-81e1ec91c1ba&displaylang=zh-cn
Whether SQL Server 2005 allows mixed logins, you may only allow Windows authentication
SQL Server 2005 uses ' SQL Server Authentication ' to log on because the ' user ' sa ' login failed. The user is not associated with a trusted SQL Server connection '.
The specific methods are:
1: Open SQL Server Manager Manager! Find ' security ' on the left click to select ' New ', ' login ' to pop up a dialog box, enter your login number in the login, select ' SQL Server Authentication ', and enter a password to remove the ' user must change password at next login '. Click on ' User mapping ' to select the database tutorial to map on the right, and tick the front! Tick the ' db-owner ' and ' public ' front in the column below. Then click ' Status ' in the right column to select "Grant", "Enable", these two are generally the default, but if the default is not the two must be changed, or not even on the! Click ' OK '.
2: Locate the SQL Server, in the left column above, right-click, in the pop-up menu select "Properties" command. Pop up a dialog box, click Security, and under Server Authentication, select SQL Server and Windows Authentication mode, and tick ahead! Remember this step is very important, if not this step you do not want to login success! Then click "OK" to do it!
3: Restart the service to choose SQL Server Authentication Mode login! Enter just the user name and password can be logged in successfully! (Restart service)