JSP connection SQL Server 2005 and connection failure resolution

Source: Internet
Author: User
Tags microsoft sql server sql server driver

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.