Solve the Problem of connecting JDBC database to SQL Server 2000

Source: Internet
Author: User

In the second half of my senior year, I finished my graduation project and went out for an interview,
Many of them want to understand JSP, so I started to learn JSP,
At the beginning, it was hard to get stuck. The problem of connecting to SQL Server through JDBC was that it could not be successful after a day. Then it would be worth the effort !!
1. Download and install Microsoft SQL Server 2000 Service Pack 3A. Select the hybrid installation mode for SQL !!!
Http://www.microsoft.com/downloads/details.aspx? Familyid = 90dcd52c-0488-4e46-afbf-ace5107fa3 & displaylang = ZH-CN

2. Download SQL Server 2000 driver for JDBC Service Pack 3
Http://www.microsoft.com/downloads/details.aspx? Familyid = 07287b11-0502-461a-b138-2aa54bfdc03a & displaylang = en

3. Disable the firewall during running

4. Test the connection and create a new JSP file to write code.

<% @ Page contenttype = "text/html; charset = gb2312" %>
<% @ Page import = "Java. SQL. *" %>
<HTML>
<Title> test SQL server </title>
<Head> <Body>
<%
Try
{Out. Print ("load the database driver ...");
Class. forname ("com. Microsoft. JDBC. sqlserver. sqlserverdriver"). newinstance ();
Out. Print ("database driver loaded successfully ...");
String url = "JDBC: Microsoft: sqlserver: // ACER-81ABD5BF54: 1433; databasename = db_job ";
Connection conn = drivermanager. getconnection (URL, "sa", "sa ");
Out. Print ("connected to the database! ");
Out. Print ("START database query ...");
Statement stmt = conn. createstatement ();
Resultset rs = stmt.exe cutequery ("select * From tb_admin ");
Out. Print ("the database is queried successfully! ");
}
Catch (exception e ){
Out. Print ("database operation failed! "+ E. tostring ());
}
%>
</Body>
</Html>

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.