Several methods of java operating XMLType

2010-02-05  来源:本站原创  分类:Java  人气:485 

XMLType is the oracle database-specific data types can be used to store a xml, through java (This article uses the jdbc) Insert XMLType parameters according to the type of sql usually have the following three kinds of methods:
This article uses a database oracle10.2.1
1, String, the client simply pass a string parameter, the task of creating xmltype entirely to the database, this method is the most stressful database

String sql = "insert into xmltable (XML) values(sys.xmlType.createXML(?))";
             String xmldata = "<label>This is an XML fragment</label>";
             ps.setString(1, xmldata);
             ps.executeUpdate();

2, CLOB, the client-side to create a good database CLOB passed through the oracle database XMLTYPE () function is constructed XMLType type of value, this method is client-side and database side also undertakes the task of creating xmltype, so the pressure of the database center

Connection conn = ... ;// Get the Connection
             PreparedStatement ps = ...;// Get PreparedSatement  

             String sql = "insert into xmltable (XML) values(XMLType(?))";
             String xmldata = "<label>This is an XML fragment</label>";

             // Created by conn CLOB
             CLOB tempClob = CLOB.createTemporary(conn, false, CLOB.DURATION_SESSION);
             // Open the CLOB
             tempClob.open(CLOB.MODE_READWRITE);
             // Get writer
             Writer clobWriter = clob.setCharacterStream(100);
             // Writing data
             clobWriter.write(xmldata);
             // Refresh
             clobWriter.flush();
             // Close the writer
             clobWriter.close();
             // Close the CLOB
             tempClob.close();

             ps.setObject(1, tempClob);
             ps.executeUpdate();

3, XMLType, the client passes an XMLType to the database, this method will create xmltype the task entirely to the client, so the minimum pressure of the database

Connection conn = ... ;// Get the Connection
             PreparedStatement ps = ...;// Get PreparedSatement  

             String sql = "insert into xmltable (XML) values(?)";
             String xmldata = "<label>This is an XML fragment</label>";
             // Create an XMLType object
             XMLType xmltype = XMLType.createXML(conn, xmldata);

             ps.setObject(1, xmltype);
             ps.executeUpdate();

The above three methods by the insertion of 200,000 data test comparison showed that:
The first method: the shortest time-consuming, the server cpu consumed the greatest
The second method: the longest time-consuming, the server cpu consumption of the middle
The third method: time-consuming center, server, minimum cpu consumption

Several methods of java operating XMLType Crown reputation ◆ breeze Communications - BlackBerry Experience Center-BLACKBERRY full support for cash on delivery

Sincerely hope that friends can leave behind valuable advice, appreciate it!

相关文章
  • Several methods of java operating XMLType 2010-02-05

    XMLType is the oracle database-specific data types can be used to store a xml, through java (This article uses the jdbc) Insert XMLType parameters according to the type of sql usually have the following three kinds of methods: This article uses a dat

  • JAVA operating ZIP file collection 2010-09-26

    JAVA operating ZIP file collection Article Transfer from: http://www.abcjava.com/html/JAVA/JAVAjichu/2009/1018/1080.html Multiple files in the network transmission time, if a transfer is often a very time-consuming, but also consume more computer sys

  • [Transfer] java operating system to determine 2010-10-28

    Attribute class Java Properties class inheritance are as follows: java.lang.Object  + - java. Util.Dictionary     + - java. Util.Hashtable        + - java. Util.Properties The application begins execution, the program first read the syste

  • Java operating office 2007 documents 2009-04-14

    We want to Office 2007 platform as a rich client application to build a basic platform, and through different means of using Java to interoperate. However, there is an Office / Java interoperability aspects not taken into account, it is to make Offic

  • the creation of java operating log 2010-08-20

    log4j log information recording system, mainly abnormal information! Or user-defined information, facilitate the user or programmer, found the error message in time to adjust, modify the bug. The user login system, it carried out after the operation

  • String class methods in Java and description (a) 2010-10-19

    String: string type First, the constructor String (byte [] bytes): string object through the byte array constructor. String (char [] value): String object constructed by an array of char. String (Sting original): Constructs a copy of the original. Ie

  • String class methods in Java and that (b) 2010-10-19

    Java String class in the common methods: public char charAt (int index) Back to index a string of characters; public int length () Returns the string length; public int indexOf (String str) Returns the string position of first occurrence of str; publ

  • java operating excel POI and jExcelAPI 2010-12-17

    Personal feelings are similar, may be the excel not know much about it ~ ~ ~ A method of operating Excel Java (JExcelAPI) MS spreadsheet (Excel) is an important member of Office, is to preserve a common format for statistical data. As office document

  • Java operating Hbase to build the table. Delete tables and data CRUD on the condition query 2011-10-08

    1, built environment New JAVA project, add the package are: For the Hadoop hadoop-core-0.20.204.0.jar For Hbase of hbase-0.90.4.jar, hbase-0.90.4-tests.jar and Hbase resource package lib directory of all the jar packages 2, the main program package c

  • Java operating cell phones, send text messages 2009-01-09

    Author: Cao Qi Blog: http://blogs.sun.com/greysh Web: http://www.greysh.com Email: Qi.Cao @ Sun.com This link: http://developers.sun.com.cn/blog/functionalca/entry/java% E6% 93% 8D% E4% BD% 9C% E6% 89% 8B% E6% 9C% BA% E5% 8F% 91% E9% 80% 81% E7% 9F%

  • JAVA operating word reading template files 2010-03-23

    Want to do a java action word of the program, to achieve reading the template file, modify the part, generate a new file such a function. package zb; import java.io.File; import java.io.FileInputStream; import java.io.FileWriter; import java.io.IOExc

  • java operating openDS 2010-05-14

    -------------------------------------------------- ---------------------------------- -------------- Memo ------------------------------------- public class OpenDSExamples { public static void main(String[] args) throws NamingException { DirContext d

  • java operating json dependencies 2010-06-10

    Learned to use ajax j2ee after, sometimes the client from the server to return data objects, their json string error-prone manual put together by Google that the json-lib the library to facilitate the support java objects to json string transformatio

  • Equals methods of Java objects 2010-07-06

    We all know that in Java, the object of comparison, if the use of "==" comparison is the object of the application, but is more of an object equals the content. Generally, we design a class, you need to override the parent class's equals method,

  • jxl.jar Package Introduction / java operating excel jxl.jar Download 2010-10-04

    Download: http://www.andykhan.com/jexcelapi/ current maximum version is 2.6. Real Download: http://www.andykhan.com/jexcelapi/download.html On its website features the following description: ● support for all versions of Excel 95-2000 ● ● generate su

  • Encountered a good explanation of various classes and methods in java web site 2011-04-27

    http://www.gznc.edu.cn/yxsz/jjglxy/book/Java_api/java/lang/String.html

  • JAVA operating in CSV (export and import). 2011-07-11

    Turn: http://blog.csdn.net/ititjt/article/details/1602760 import java.io. *; public class csvbean ... { public static void main (String [] args) ... { try ... { File file = new File ("C: / name.csv"); FileOutputStream out = new FileOutputStream

  • example of java operating mongo DB database 2011-06-22

    package com.tompig.ljc; import java.net.UnknownHostException; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Set; import com.mongodb.BasicDBObject; import com.mongodb.DB; import com.mongodb.DBCollection; im

  • Java operating MongoDB example - CRUD 2011-09-13

    import java.net.UnknownHostException; import java.util.Iterator; import java.util.Set; import com.mongodb.BasicDBObject; import com.mongodb.DB; import com.mongodb.DBCollection; import com.mongodb.DBCursor; import com.mongodb.DBObject; import com.mong

  • java operating xml (sax, dom, jdom, dom4j) CRUD search 2010-07-09

    http://www.javaeye.com/topic/612837