Example of JDBC database access (1)

Source: Internet
Author: User

Example of JDBC database access

JAVA's cross-platform processing capabilities (Write Once, Run Anywhere) and excellent image processing capabilities (I believe there is no such language that can surpass JAVA's network processing capabilities) network communication functions, JDBC database access technology, and so on, it is undeniable that the JAVA language is SUN's great contribution to the computer industry. I can describe this scenario: one day you can access the Internet without using IE or NETSCAPE. surfing the internet is like playing a game, and you can get the beautiful images and interactions of the game, if you have played UO, you may know that feeling, but JAVA will definitely make more things than UO, because it is not just a game, it is not just a browser, if you want to (if you want to have money, time, and excellent JAVA talents), you can fully integrate all this with Java !!! I'm not exaggerating the JAVA feature, you can visit the Community Program of http://www.simchina.net, you can find a feeling: Believe I Didn't Say Anything false. Now I will introduce you to JAVA's database access technology-JDBC database access technology (you should never turn it into ODBC !).

In fact, JDBC is an application interface (API) that can access any structured database using the JAVA language (I don't know whether it is true, as Sun said ), in addition, JDBC 3.0 can also access spreadsheet programs such as Execel, according to Sun!

There are four methods for JDBC to access the database. Here we only introduce two methods:

The first is to access the database through ODBC as the Bridge, and the second is to access the database directly.

Let's take a look at the first JDBC <--> ODBC access process:

JDBC Driver Mannager-> JDBC <-> ODBC bridge-> ODBC-> database client Driver library-> database server-> return query results, in this way, we note that although JAVA is "Write Once, Run Anywhere", if this access is used, the client must set ODBC and the driver of the corresponding database client, when you read the other process below, you may think: why is there a more obvious problem! Well, because not all database server providers provide the following JDBC drivers (providing corresponding interfaces for JDBC access), JDBC <-> ODBC Bridge is available.

Next let's take a look at the second access process:

JDBC Driver Mannager-> Local JDBC Driver-> client database-> database server-> return query results. In fact, this access is converted to the corresponding database (Oracle, Sybase, Informix, DB2, and other database management systems) Client API call (so, I don't know if you can understand it. To put it simply, ASP does not access the database through DSN but through OLEDB, I still don't know if you can understand what I mean. Oh, don't throw eggs !), This access method requires the corresponding database provider to provide the corresponding JDBC driver, but there is a benefit that odbc can be used independently in the browser Applet program of clients that can Run anywhere.
We will give you an example of access through the JDBC-ODBC bridge database, but before looking at the example below I want to ask you once: JDK1.3 installed? Is the database Driver Installed (I am using SQLserver )? Shouldn't you use Linux? Although java supports Linux, I didn't use Linux, dude (this is irrelevant to JAVA's Write Once and Run Anywhere), because ODBC running under Win is used, I suggest you take a look at this http://www.aspcn.com/showarticle.asp? Id = 112. Otherwise, if you have a problem and you cannot get the result, it's not a blame for me (but it's just a sin to add, why don't you eat it!


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.