How to import xml into a database by using JAVA
We know that there are many ways to import data into the database by inserting data into the database by importing xml into the database. In the past, the most commonly used method was to insert a piece of data through SQL statements, today, we will learn to add the data in xml to the database once:
First, write an xml file:
Then write the method to read the xml file: Introduce the dom4j jar package to lib under WEB-INFO and add references:
Imp
(!conn. Getautocommit ()) {Conn.rollback ();}}} catch (SQLException e) {}}//Resets the database connection, reverts to the original state public static void Resetconnection (Connection conn) {try {if (conn! = null) {if (Conn.getautocommit ()) {Conn.setautocommit (false);} else {Conn.setautocommit (true);}}} catch (SQLException e) {}}public static void main (string[] args) {System.out.println (dbutil.getconnection ());}}2.3. The Testxmlimport class is used to read the information in the XML file
());}}
2.3. The TestXMLImport class is used to read the information in the XML file and write it into the database table.
Package com. bjpowernode. xml; import java. io. file; import java. SQL. connection; import java. SQL. preparedStatement; import java. SQL. resultSet; import java. util. iterator; import java. util. list; import org. dom4j. document; import org. dom4j. element; import org. dom4j. io. SAXReader; public class TestXMLImport {/*** @ param args */public static void main (String []
When encapsulation, we often need to use XML to define some specifications, while running the read alone is certainly not a problem, but these XML is often put in the jar bag, so that these things can not find out. The XML definitions used in this article are as follows:
Copy Code code as follows:
Here's a look at the code:
Copy Code code as follows:
public void read () {
try {
nbs p; Document doc = new Saxreader (). Read (New File ("Src/user.xml");
We know there are many ways to Import XML into a database by inserting the number into the database.,most of the previous contacts were throughSQLthe statement simply inserts a single piece of data,to learn today is toXMLdata is added to the database at once:the first thing to write is an XML file : and then write the ReadXMLmethod of the file:putdom4jof theJarpackage introduced toWeb-infounder theLiband add a reference:Import org.dom4j.document;import org.dom4j.element;import org.dom
When I first came into contact with dom4j, I felt this thing was mysterious, because although I knew about XML files before, I never used it. I always felt that XML is definitely not easy to operate. When I learned that dom4j can easily read XML files, how simple is it to read XML files using dom4j? Let me take a look.
First, let's take a look at the structure of the XML file:
Step 1: Introduce the jar file, introduce the dom4j-1.6.1.jar file and jaxen-1.1-beta-6.jar File
Step 2: write a few
exception, such as converting a string to a number. The code is as follows:
Copy Code code as follows:
public class Task implements Runnable {
@Override
public void Run () {
int numero = integer.parseint ("diguage.com");
}
}
3. Create the main class of the program, main class, and then implement the main () method. The code is as follows:
Copy Code code as follows:
public class Main {
public static v
Application 1:-------1. Import the jar packages of dom4j and jaxen2. Reading is easier than pure dom4j:Document Doc = new saxreader (). Read (new file ("D:/share/javaprojects/DRP/test_xmlimport/XML/test01.xml "));List itemlist = Doc. selectnodes ("/ACCESOS/item/socio"); // dom4j + xpathFor (iterator iter = itemlist. iterator (); ITER. hasnext ();){Element El = (element) ITER. Next ();String numero = El. elementtext ("
When I first came into contact with dom4j, I felt this thing was mysterious, because although I knew about XML files before, I never used it. I always felt that XML is definitely not easy to operate. When I learned that dom4j can easily read XML files, how simple is it to read XML files using dom4j? Let me take a look.
First, let's take a look at the structure of the XML file:
To read an XML file using dom4j, you only need two steps:
Step 1: Introduce the JAR file, introduce the dom4j-1.6.1.ja
Dynamically generated controls, it should be written like this: with do begin Parent:=panelcheque; Name:='Bank'+curnumber; Left:=+; Top:=curtop; Height:=; Width:=n; Text:='; End;But accidentally wrote: with do begin Parent:=panelcheque; Name:='numero'+curnumber; Left:=; Top:=curtop; Height:=; Width:=; Text:='; End;Result error: A
detailed"Uuno on Numero yksi" (Slogan for a series of Finnish movies.)This chapter describesInitProcess, which is the first user-level process that the kernel initiates.InitThere are many important tasks, such as startingGetty(for user logons), implementing RunLevel, and handling orphaned processes. This chapter explains how to configure theInitAnd how to use different levels of operation. The first stepInitFor the operation of the Linux system,InitP
"I would like to introduce virtualization technology in a step-by-step manner, but the recent work in analyzing open vswitch technology, I want to take advantage of the memory of the openvswitch of the understanding of the detailed summary down"
This article summarizes the documentation provided by Openvswitch website openvswitch. org, as well as other relevant materials.
Open Vswitch Overall Overview:
> Apache 2.0 protocol.
> Software-only multilayer virtualization switches.
> Support OpenFlow
= u + 00a4: currency signA5 = u + 0490: Cyrillic capital letter ghe with upturnA6 = u + 00a6: Broken barA7 = u + 00a7: Section signA8 = u + 0401: Cyrillic capital letter IoA9 = u + 00a9: Copyright signAA = u + 0404: Cyrillic capital letter Ukrainian IEAB = u + 00ab: Left-pointing double angle quotation markAC = u + 00ac: not signAD = u + 00ad: Soft hyphenAE = u + 00ae: registered signAF = u + 0407: Cyrillic capital letter YiB0 = u + 00b0: Degree signB1 = u + 00b1: plus-minus signB2 = u + 0406:
This article is a summary of the study of the article on the network, thank you for your selfless sharing.1 , Java in a 2 type of exception:Check for exceptions: These exceptions must be forced to capture them or in a method throws clause. No exception checked: These exceptions do not have to be forced to capture them.2 , in a thread object's Run () method throws a check exception, we must capture and process them. Because the run() method does not accept the throws clause. When a non-check exce
is effectively complementary to white.
M2b
The cheerful translucent gradient reinforces the visual performance of the site. As a result of this approach, the new colors make the image behind the sudden color. White is used as a supplemental color to make the content look eye-catching.
Lovedays
The designer uses a flat style on the Welcome page. Minimalist design contains only a few outline elements, simple fonts, simple buttons, and a city background map. The latter is combined wi
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.