Accessing SQL Server 2000 databases in Java

Source: Internet
Author: User
Tags driver manager odbc access database

Absrtact: This article mainly introduces the use of JDBC, ODBC interface to achieve the connection with SQL Server2000 database, and use Java application to access it, at the same time through the graphical user interface to achieve a simple query function.

Objective

Database technology and network technology are two hot topics in the field of computer science, and the database technology has been developed in technology since its generation. And as the front-end access to development tools and environment is still in the continuous improvement and development, in addition to the use of the network ASP, PHP, JSP as the front-end connection database technology, small systems commonly used Access database technology Delphi, Visual Basic, PowerBuilder and vc+ + And so on, and Java is one of them.

The Java language is one of the outstanding languages for writing database applications, and it provides the technology to facilitate access to data. Using JDBC technology in Java language, users can easily develop a database access program based on Web page, thus expanding the network application function. JDBC (Java DB Connectivity,java database connection) is a Java API for executing SQL statements that provides a unified access interface for a variety of relational databases. JDBC consists of a set of classes and interfaces written in the Java language that enable users to connect to many different database systems in a consistent way (such as Access, SQL Server 2000, Oracle, Sybase, and so on) by invoking the methods provided by these classes and interfaces. You can then use the standard SQL language to access the data in the database without having to write different Java program code for each database system.

SQL Server2000 is a new generation of Microsoft database products, it is built on the solid foundation of SQL Server7.0, and a large number of SQL Server7.0 expansion. SQL Server2000 delivers scalability and high reliability for the largest Web sites and enterprise-class applications with the support of high-end hardware platforms and the latest network and storage technologies.

Java Access database via JDBC, ODBC interface

1 JDBC, ODBC interface

The Java application connects to the database through the JDBC API (java.sql), and the actual action is connected to the database system by the JDBC Driver Manager (JDBC Driver manager) through the JDBC driver. ODBC (Open DataBase connectivity), an open interface, provides users with a standard interface for accessing relational databases, which provides a unified set of APIs for different databases ; You can enable applications to access any database that provides ODBC drivers through the API, and all relational databases currently provide ODBC drivers, so ODBC has become the industry standard for database access and has been widely used.

The Jdbc-odbc Bridge is a JDBC driver that is implemented by converting JDBC operations into ODBC operations. The use of the Jdbc-odbc Bridge allows program developers to write JDBC applications without learning more knowledge and to take full advantage of existing ODBC data sources. The JDBC-ODBC bridge driver can enable JDBC to access almost all types of databases.

2 Accessing SQL Server2000 databases with Java applications

(1) Establishing a database

Start Microsoft SQL Server2000, open Enterprise Manager to create a database named "MyData" in database, and make a datasheet named "Wuzi" below it, as shown in Figure 1.

Figure 1

(2) establishing (ODBC) data sources and drivers

Open the ODBC Data Source Administrator dialog box on the control panel through the data Source (ODBC) of Administrative Tools. Click the System DSN tab, and then click the Add button to get the Create Data Source dialog box, select SQL Server and click Finish to the Create a new data source to the data source name item in the SQL Server dialog box fill in "Wzgl" and choose "Server Name". Then click the Next button, select the Windows NT Authentication with network logon ID project, click Next, and change the default database to MyData, click Next, click Finish, and then click Test Data Source, and then click OK to complete the (ODBC) data source and driver setup.

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.