Java database Programming and Java XML Parsing technology

Source: Internet
Author: User
Tags cdata object model processing instruction xml parser xsl

1.JDBC Overview

A. What is JDBC?

Java DataBase Connectivity: is a Java API for executing SQL statements, consisting of a set of classes and interfaces written in the Java language. Through these classes and interfaces, JDBC sends SQL statements to different types of databases for processing and receiving processing results

B. Common classes and interfaces for JDBC: DriverManager class, connection interface, statement interface, PreparedStatement interface, resultset interface

2.JDBC Programming Steps

1). Load Driver

Class.forName ("");

2). Create a connection (Connection) object

Connection c= drivermanager.getconnection ("path", "username", "password");

3). Create a declaration statement object using a Connection object

Statement s = c.createstatement ();

4). Manipulating data or querying data

5). Close various objects

3. Learn about the four drivers for JDBC

A. Jdbc-odbc Bridge:jdbc-odbc Bridge

The universal drive from Sun provides access to a variety of databases, but with minimal efficiency.

B. Native-api Partly-java Driver: local library Java Driver

The execution efficiency is high, the client must install the local drive, the maintenance is inconvenient.

C. net-protocal All-java Driver (JDBC Proxy): Network protocol Pure Java driver (generic)

The client does not have to install a local library and is easy to use, but has relatively low performance.

D. native-protocal All-java Driver: Local protocol full Java driver

It is highly efficient to convert JDBC calls into a network protocol for a specific database.

4. Managing result Sets

A. Why use A result set?

The result set needs to be moved and processed repeatedly

It's another way for JDBC to treat datasets as objects

B. What is a result set: a result set is an object mapped to a database of information (such as a table)

C. Classification of result sets

Scrollable result set

Updatable result set

5.XML Overview

A. What is XML?

XML (Extended Markup Language): Extensible Markup Language

6. XML Syntax rules

A.xml statement

A. XML declarations are generally the first line of an XML document

B. The XML declaration consists of the following parts:

Version: The document conforms to the XML1.0 specification and is now only 1.0

Encoding: Document character encoding, default to "UTF-8"

Standalone: Whether the document definition is within a file

(standalone= "yes", standalone= "no")

Example: <?xml Version = "1.0" encoding= "utf-8" standalone = "yes"?>

B. XML comment:<!--This is a comment--

Note: Do not appear in the comment content, do not place the note in the middle of the tag, the comment cannot be nested, and you can place comments anywhere except the tag.

C.xml processing Instructions

A. Processing instructions FOR XML parser passing information to an application

B. Format: < processing instruction name processing instruction information?>

<?xml:stylesheet type= "text/xsl" href= "example.xsl"?>

D. XML elements

A. Relationships between elements: child elements/parent elements, ancestors/descendants

Type of element content: nested element/character data/entity reference/CDATA section/processing instruction/Comment

B. XML root element: Each XML document must have only one root element, the root element is an element that completely includes all other elements in the document, the start tag of the root element is placed before the start tag of all other elements, and the end tag of the root element is placed after the end tag of all other elements.

C. XML entities

&lt:<

&gt:>

&amp:&

&quot: "

&apos: '

D. Naming rules FOR XML element tags:

1). The name can contain letters, numbers, or other characters

2). The name cannot begin with a number and a "_" (underscore)

3). Not to xml/xml/xml/... Beginning

4). The name cannot contain spaces

5). The name cannot contain a colon (note: The colon is reserved for use by the namespace)

E.cdata: Used to interpret an entire paragraph of text as pure character data rather than as a marker. Contains a large number of <, >, &, or "characters. All characters in a CDATA section are treated as constant portions of the element's character data, rather than as XML tags.

Note: CDATA is text that is not parsed by the parser. tags within the text are not treated as tokens and entities are not expanded.

Grammar:

<! [cdata[

。。。。。。。。

]]>

F.xml element attributes: Attribute values are separated by double quotation marks (") or single quotation marks (') (if there are ', separated by ') in the attribute value;

An element can have multiple properties, the basic format of which is:

< element Name Property name = attribute value >

A specific property name can only appear once in the same element tag

Attribute values cannot include <,;, &

7. Overview of the XML technology system

A. Document description and validation techniques: Both DTD and schema are used to define the XML structure and to verify that the XML document we write conforms to the requirements of the technology

B. Document conversion technology (XSL/XSLT)

C. Document query Technology (xpath/xquery)

D. Document parsing Technology (XML Dom/sax)

E. Document linking and positioning technology (Xlink/xpointer)

8. XML parsing Technology

A. Document Object Model (DOM), an API based on tree structure

B.xml Simple API (sax), an event-driven implementation of apic.dom and SAX parsing techniques A.jaxp (Java API for XML) b.jdom c.dom4j:

Parsing common methods

Saxreader Saxreader = new Saxreader ();

Document document = Saxreader.read (inputfile);

SelectNodes ()

GetValue ()

Elementiterator ()

Java database Programming and Java XML Parsing technology

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.