亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? saveipinfo.java~1~

?? 課程設計案例精編光盤源碼 課程設計案例精編光盤源碼
?? JAVA~1~
字號:
package tsinghuaip;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.PreparedStatement;
import org.w3c.dom.Document;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class SaveIPInfo {

   public static void main (String args[]){

       //Create the Document object
      Document mapDoc = null;
      //Define a new Document object
      Document dataDoc = null;
      //Create the new Document
      Document newDoc = null;
      try {
         //Create the DocumentBuilderFactory
         DocumentBuilderFactory dbfactory = DocumentBuilderFactory.newInstance();
         //Create the DocumentBuilder
         DocumentBuilder docbuilder = dbfactory.newDocumentBuilder();
         //Parse the file to create the Document
         mapDoc = docbuilder.parse("mapping.xml");
         //Instantiate a new Document object
         dataDoc = docbuilder.newDocument();

         //Instantiate the new Document
         newDoc = docbuilder.newDocument();
      } catch (Exception e) {
         System.out.println("Problem creating document: "+e.getMessage());
      }

      //Retrieve the root element
      Element mapRoot = mapDoc.getDocumentElement();
      //Retrieve the (only) data element and cast it to Element
      Node dataNode = mapRoot.getElementsByTagName("data").item(0);
      Element dataElement = (Element)dataNode;
      //Retrieve the sql statement
      String sql = dataElement.getAttribute("sql");

      //Output the SQL statement
      System.out.println(sql);

      //For the JDBC-ODBC bridge, use
      //driverName = "sun.jdbc.odbc.JdbcOdbcDriver"
      //and
      //connectURL = "jdbc:odbc:pricing"
      String driverName = "JData2_0.sql.$Driver";
      String connectURL = "jdbc:JDataConnect://127.0.0.1/pricing";
      Connection db = null;
      //Create the ResultSetMetaData object, which will hold information about
      //the ResultSet
      ResultSetMetaData resultmetadata = null;

      //Create a new element called "data"
      Element dataRoot = dataDoc.createElement("data");

      try {
         Class.forName(driverName);
         db = DriverManager.getConnection(connectURL);
      } catch (ClassNotFoundException e) {
         System.out.println("Error creating class: "+e.getMessage());
      } catch (SQLException e) {
         System.out.println("Error creating connection: "+e.getMessage());
      }

      //Create the Statement object, used to execute the SQL statement
      PreparedStatement statement = null;
      //Create the ResultSet object, which ultimately holds the data retreived
      ResultSet resultset = null;
      try {
         statement = db.prepareStatement("select * from products");
         //Execute the query to populate the ResultSet
         resultset = statement.executeQuery();

         //Get the ResultSet information
         resultmetadata = resultset.getMetaData();
         //Determine the number of columns in the ResultSet
         int numCols = resultmetadata.getColumnCount();

         //Check for data by moving the cursor to the first record (if there is one)
         while (resultset.next()) {
            //For each row of data
            //Create a new element called "row"
            Element rowEl = dataDoc.createElement("row");
            for (int i=1; i <= numCols; i++) {
               //For each column index, determine the column name
               String colName = resultmetadata.getColumnName(i);
               //Get the column value
               String colVal = resultset.getString(i);
               //Determine if the last column accessed was null
               if (resultset.wasNull()) {
                  colVal = "and up";
               }
               //Create a new element with the same name as the column
               Element dataEl = dataDoc.createElement(colName);
               //Add the data to the new element
               dataEl.appendChild(dataDoc.createTextNode(colVal));
               //Add the new element to the row
               rowEl.appendChild(dataEl);
            }
            //Add the row to the root element
            dataRoot.appendChild(rowEl);

         }
      } catch (SQLException e) {
         System.out.println("SQL Error: "+e.getMessage());
      } finally {
         System.out.println("Closing connections...");
         try {
            db.close();
         } catch (SQLException e) {
            System.out.println("Can't close connection.");
         }
      }
      //Add the root element to the document
      dataDoc.appendChild(dataRoot);
      //Retrieve the root element (also called "root")
      Element newRootInfo = (Element)mapRoot.getElementsByTagName("root").item(0);
      //Retrieve the root and row information
      String newRootName = newRootInfo.getAttribute("name");
      String newRowName = newRootInfo.getAttribute("rowName");
      //Retrieve information on elements to be built in the new document
      NodeList newNodesMap = mapRoot.getElementsByTagName("element");

      //Create the final root element with the name from the mapping file
      Element newRootElement = newDoc.createElement(newRootName);

      //Retrieve all rows in the old document
      NodeList oldRows = dataRoot.getElementsByTagName("row");
      for (int i=0; i < oldRows.getLength(); i++){

         //Retrieve each row in turn
         Element thisRow = (Element)oldRows.item(i);

         //Create the new row
         Element newRow = newDoc.createElement(newRowName);

         for (int j=0; j < newNodesMap.getLength(); j++) {

            //For each node in the new mapping, retrieve the information
            //First the new information...
            Element thisElement = (Element)newNodesMap.item(j);
            String newElementName = thisElement.getAttribute("name");

            //Then the old information
            Element oldElement = (Element)thisElement.getElementsByTagName("content").item(0);
            String oldField = oldElement.getFirstChild().getNodeValue();


            //Get the original values based on the mapping information
            Element oldValueElement = (Element)thisRow.getElementsByTagName(oldField).item(0);
            String oldValue = oldValueElement.getFirstChild().getNodeValue();

            //Create the new element
            Element newElement = newDoc.createElement(newElementName);
            newElement.appendChild(newDoc.createTextNode(oldValue));

            //Retrieve list of new elements
            NodeList newAttributes = thisElement.getElementsByTagName("attribute");
            for (int k=0; k < newAttributes.getLength(); k++) {
               //For each new attribute
               //Get the mapping information
               Element thisAttribute = (Element)newAttributes.item(k);
               String oldAttributeField = thisAttribute.getFirstChild().getNodeValue();
               String newAttributeName = thisAttribute.getAttribute("name");

               //Get the original value
               oldValueElement = (Element)thisRow.getElementsByTagName(oldAttributeField).item(0);
               String oldAttributeValue = oldValueElement.getFirstChild().getNodeValue();

               //Create the new attribute
               newElement.setAttribute(newAttributeName, oldAttributeValue);
            }

            //Add the new element to the new row
            newRow.appendChild(newElement);

         }
         //Add the new row to the root
         newRootElement.appendChild(newRow);
      }
      //Add the new root to the document
      newDoc.appendChild(newRootElement);

      System.out.println(newRootElement.toString());
   }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美videofree性高清杂交| 在线免费一区三区| 亚洲第一综合色| 依依成人精品视频| 亚洲三级视频在线观看| 亚洲同性gay激情无套| 国产日本欧洲亚洲| 欧美激情一区在线观看| 亚洲国产电影在线观看| 中文子幕无线码一区tr| 久久久精品欧美丰满| 国产日产亚洲精品系列| 久久久不卡网国产精品一区| 久久伊人蜜桃av一区二区| 国产欧美综合在线| 亚洲欧洲综合另类| 午夜欧美在线一二页| 久久国产尿小便嘘嘘尿| 处破女av一区二区| 91久久精品一区二区三区| 精品视频资源站| 欧美成人欧美edvon| 国产精品网站一区| 亚洲国产精品嫩草影院| 蜜臀va亚洲va欧美va天堂| 国产精品一区二区三区99| 91老师片黄在线观看| 欧美性大战久久久久久久蜜臀 | 久久精品亚洲乱码伦伦中文| 久久午夜羞羞影院免费观看| 中文字幕永久在线不卡| 亚洲国产wwwccc36天堂| 久久99热99| 99国产精品99久久久久久| 精品视频1区2区3区| 欧美www视频| 国产精品少妇自拍| 日本欧美加勒比视频| 成人久久18免费网站麻豆| 欧美日韩二区三区| 国产精品萝li| 全国精品久久少妇| 99久久免费精品高清特色大片| 欧美日韩第一区日日骚| 中文字幕av一区二区三区免费看| 亚洲国产成人高清精品| 国产精品一级在线| 日韩一区二区三区免费观看| 国产精品夫妻自拍| 久久er99精品| 欧美剧情片在线观看| 国产精品无人区| 激情伊人五月天久久综合| 欧美日韩一本到| 成人免费视频在线观看| 久久成人av少妇免费| 欧美日韩一区高清| 综合久久久久久久| 国产精品996| 欧美精品一区二区三区高清aⅴ | 免费在线看一区| 91行情网站电视在线观看高清版| 久久久不卡网国产精品一区| 久久精品国产亚洲5555| 欧美亚洲综合久久| 亚洲自拍都市欧美小说| www.色综合.com| 亚洲国产岛国毛片在线| 国产老肥熟一区二区三区| 欧美成人精品1314www| 水野朝阳av一区二区三区| 欧美在线观看禁18| 亚洲一区二区影院| 在线观看视频欧美| 午夜精品免费在线| 欧美日韩中文一区| 日韩高清一区二区| 欧美一级片在线看| 久久国产夜色精品鲁鲁99| 日韩视频在线你懂得| 麻豆精品久久久| 26uuu国产电影一区二区| 国内精品在线播放| 国产日韩精品一区二区三区 | 欧美麻豆精品久久久久久| 亚洲一区中文日韩| 欧美日韩第一区日日骚| 男男gaygay亚洲| 久久午夜羞羞影院免费观看| 国产91高潮流白浆在线麻豆| 中文字幕第一区| 日本韩国精品在线| 亚洲成人www| 欧美不卡在线视频| 国产一二精品视频| 亚洲色图视频网| 在线不卡一区二区| 久久草av在线| 亚洲欧美在线另类| 欧美精品1区2区| 国产精品综合一区二区三区| 国产精品国产a级| 欧美日韩中文国产| 国产在线日韩欧美| 国产精品美女视频| 制服丝袜在线91| 国产伦精一区二区三区| 亚洲情趣在线观看| 91精品国产欧美一区二区成人| 国产一区在线精品| 亚洲免费av在线| 欧美精品一区二区三区一线天视频| 国产99久久久久| 天堂va蜜桃一区二区三区| 欧美精品一区二区三区高清aⅴ| 99精品欧美一区二区三区综合在线| 亚洲电影一区二区| 国产欧美一区视频| 欧美日韩免费在线视频| 国产大陆a不卡| 亚洲va韩国va欧美va精品| 久久精品人人做| 日韩欧美国产综合| 欧美探花视频资源| 成人av免费在线| 久久99精品一区二区三区三区| 亚洲婷婷国产精品电影人久久| 精品久久五月天| 91精品国产福利| 色呦呦一区二区三区| 国产一区二区三区久久久| 亚洲网友自拍偷拍| 欧美国产激情二区三区| 欧美成人一区二区| 欧美视频三区在线播放| www.日韩精品| 国产精品456露脸| 激情综合色综合久久| 石原莉奈在线亚洲二区| 亚洲精品中文在线影院| 国产精品美女久久久久久久| 日韩欧美一区二区在线视频| 在线亚洲一区二区| 本田岬高潮一区二区三区| 国产一区二区91| 国产一区在线精品| 国产一区二区三区黄视频| 久久爱另类一区二区小说| 蜜臀av性久久久久蜜臀aⅴ流畅| 午夜精品视频在线观看| 午夜精品视频一区| 喷白浆一区二区| 日本成人超碰在线观看| 免费观看日韩电影| 日本特黄久久久高潮| 奇米888四色在线精品| 久久99国产精品免费网站| 麻豆国产一区二区| 国产一区欧美一区| 国产伦精品一区二区三区免费| 青青国产91久久久久久| 日韩国产欧美在线播放| 亚洲女爱视频在线| 中文子幕无线码一区tr| 久久蜜桃香蕉精品一区二区三区| 欧美一区二区美女| 日韩一区二区视频在线观看| 9人人澡人人爽人人精品| 午夜精品福利一区二区蜜股av| 久久精品在这里| 欧美韩日一区二区三区| 日韩美女视频一区二区| 中文字幕日韩一区| 亚洲另类中文字| 中文字幕av资源一区| 一区二区三区欧美亚洲| 亚洲午夜影视影院在线观看| 亚洲制服丝袜av| 婷婷丁香激情综合| 日本免费在线视频不卡一不卡二 | 久久久久久久网| 中文字幕在线观看一区二区| 自拍偷拍亚洲欧美日韩| 综合网在线视频| 亚洲福中文字幕伊人影院| 喷水一区二区三区| 国产老女人精品毛片久久| 成人性生交大片免费看中文| 国产乱码精品一区二区三区av| 91在线一区二区| 欧美人妇做爰xxxⅹ性高电影| 欧美一区二区三区小说| 国产精品久久久久影院亚瑟 | 国产精品99久久久久久似苏梦涵| 懂色av一区二区三区蜜臀| 国产黄人亚洲片| 欧美女孩性生活视频| 精品国产精品一区二区夜夜嗨| 中文字幕av一区二区三区| 免费欧美在线视频|