Getting Started with JDBC (i)

Source: Internet
Author: User
Tags odbc requires

The first thing you need to do is to install it correctly. This includes the following steps:

Install Java and JDBC on your computer
Java Database Connectivity (JDBC) is a standard SQL (structured query Language) database provider that provides unified access to a variety of relational databases. JDBC (Java database Connection,java DB connections) also provides a benchmark by which more advanced tools and interfaces can be built. The current JDK (Java Development Kit,java Development toolkit) software bundle includes JDBC and JDBC-ODBC (open DB Connection, open database connection) bridge. These packages can also be obtained independently for use with JDK 1.0. It should be noted that the example in this article uses the JDBC 2.0 interface, which requires JDK 2.0来 to run and not run under JDK 1.1.

You can find the latest version from Http://java.sun.com/products/JDK/CurrentRelease.

Installing drivers
Your driver should have a method of installation. When you install a JDBC driver for a specific DBMSs, just copy it to your computer. No special configuration is required.

If you download a Solaris or Windows JDK1.1 version, the bridge is installed automatically with the JDK as a package sun.jdbc.odbc. For information about installing and configuring ODBC, consult your ODBC driver manufacturer. The bridge needs no special configuration. Consult your database manufacturer for client installation and configuration information.

If necessary, install the database system
If you are not sure whether to install the database system, you need to follow the vendor's requirements to install the database. Most users have already installed databases and can continue to use the databases they have installed.

Configuration database
We assume that the database Coffeebreak already exists. (Creating a database is not difficult, but requires certain permissions and is usually done by the database administrator) you will also need to create this tutorial as an example of the table used in this database. We intend to limit the size and number of the tables to facilitate management.

Suppose our database is used in a café, coffee beans are sold in pounds, and coffee is in cups. For simplicity's sake, it is also assumed that the operator needs only 2 tables to store information about different types of coffee and coffee suppliers.

First we demonstrate how to open a DBMS connection and how JDBC is sending SQL statements to your DBMS. With this code, we will show that using JDBC to pass SQL statements to your DBMS and process the returned results is very simple.

All the code was tested on several major DBMS products. However, if you use the Jdbc-odbc Bridge to connect to an older version of the ODBC driver, you may experience some compatibility issues.



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.