<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 41, comments - 15, trackbacks - 0, articles - 1
      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

    手工建庫后出現ORA-06553:PLS-213:Standard包不可訪問 問題,在網上查下了資料解決了!

    ORACLE數據庫,在一次意外操作中,使得ORACLE數據庫出現故障,提示:ORA-06553:PLS-213:Standard包不可訪問。一般都是由于操作不當引起的,如:刪除某一用戶權限、刪除某一數據等等。下面把我總結出來的處理經驗公布如下:

    另外說幾點:網上很多人的博客雖然也有說明此問題的解決方法,但都比較專業,沒有一些操作經驗的根本看不懂,也不知道如何操作,往往使讀者更糊涂。

    首先,本文測試平臺:windows 2003,oracle 9i

    我們的目標:執行catalog.sql和catproc.sql重建數據字典。

    1.點擊左下角的“開始”--運行 輸入 sqlplus /nolog

    2.使用“超級管理員”(sys)的賬戶和密碼 進入你的系統,命令如下:

    sql > connect sys/你的密碼@你的數據庫 as sysdba

    如果提示正確登錄,則已經成功一半了。如果沒有成功登錄,則參考是否忘記密碼,忘記密碼的補救不在本文的范圍,涉及到的請自行參考資料。

    3. SQL>@D:\oracle\ora90\rdbms\admin\catalog.sql

    4. SQL>@D:\oracle\ora90\rdbms\admin\CATPROC.SQL

    5. SQL>@D:\oracle\ora90\rdbms\admin\DBMSSUTIL.SQL

    6. SQL>ALTER PACKAGE STANDARD COMPILE;

    7. SQL>ALTER PACKAGE DBMS_STANDARD COMPILE;

    8. SQL>SHUTDOWN ABOUT;

    9. SQL>STARTUP;

    參考:(一般不用,如果恢復成功。)

    @ORACLE_BASE\ORACLE_HOME\rdbms\admin\utlrp.sql

    posted @ 2013-09-09 18:29 yuhaibo736 閱讀(995) | 評論 (0)編輯 收藏

    webservice的原理及概念

    1 webservice

    所謂webservice就是定義了一套標準的調用過程:

    a 服務器首先用一套標準的方法向外界描述它所提供的服務的內容,就屬于WSDL

    b 客戶端需要以一種標準的協議來調用此服務,這屬于SOAP.

    c 服務提供者將服務內容放在一個公共的網址讓大家查詢,就屬于UDDI.

    2 命名空間

    命名空間其主要目的通過加一個命名屬性,使名稱保持唯一性。WSDL有大量的使用命名空間的地方。本質上WSDL是一個XML文件,作為一個XML文件,為了區別同名的元素,就需要采用命名空間的概念。

    3 WSDL的本質:服務內容的標準化描述

    WSDL的全稱是web service Description Language,是一種基于XML格式的關于web服務的描述語言。其主要目的在于web service的提供者將自己的web服務的所有相關內容,如所提供的服務的傳輸方式,服務方法接口,接口參數,服務路徑等,生成相應的完全文檔,發布給使用者。使用者可以通過這個WSDL文檔,創建相應的SOAP請求消息,通過HTTP傳遞給webservice提供者;web服務在完成服務請求后,將SOAP返回消息傳回請求者,服務請求者再根據WSDL文檔將SOAP返回消息解析成自己能夠理解的內容。

    4 SOAP的本質:標準的傳輸協議

    SOAP是web service的標準通信協議,SOAP為simple object access protocoll的縮寫,簡單對象訪問協議. 它是一種標準化的傳輸消息的XML消息格式。

    5 UDDI的本質:服務的公共網址

    將web service進行UDDI注冊發布,UDDI是一種創建注冊表服務的規范,以便大家將自己的web service進行注冊發布供使用者查找.然而當服務提供者想將自己的web service向全世界公布,以便外部找到其服務時,那么服務提供者可以將自己的web service注冊到相應的UDDI商用注冊網站,目前全球有IBM等4家UDDI商用注冊網站。因為WSDL文件中已經給定了web service的地址URI,外部可以直接通過WSDL提供的URI進行相應的web service調用。所以UDDI并不是一個必需的web service組件,服務方完全可以不進行UDDI的注冊。

    posted @ 2013-04-23 11:17 yuhaibo736 閱讀(258) | 評論 (0)編輯 收藏

    java處理word已經存在很多種方法了,但是用起來都不是那么方便,而且不太靈活,而使用xml的方法可以做到非常靈活,你可以先建好模板,然后往里面填數,模板怎么建,填出來的效果就是怎么樣的。首先說說word和xml的關系,每個word它都對應著一個xml文件,也就是說你修改了xml,對應的word文件也就跟著修改了。通過word的保存功能可以將一個word文件保存為xml文件,該文件雖然是.xml格式的,但是直接雙擊打開的話還是使用word打開,所以你只能用txt將它打開,用txt打開之后將里面的一句話:<?mso-application progid="Word.Document"?>去掉,然后保存,接著就可以雙擊直接打開了,這樣使用的就是IE打開的,你這樣就可以查看里面的節點具體的構造。

    最上面的主節點是<w:wordDocument>(如果不是的話,相信你將word文件保存成xml的時候使用的是07word,選擇的是:word xml文檔(*.xml),你可以選擇word 2003 xml文檔(*.xml)試試);該主節點下面有大致8個節點,其中我們要操作的就是<w:body>節點,該節點是word的正文節點,其他的節點沒有去研究;<w:body>下面包含的節點可能會有:<w:p>段落節點、<w:tbl>表格節點。

    接著要做的就是在java程序中,使用dom來解析編輯xml文件,這里貼出一些代碼來供大家參考:

     

    public Document loadXML(String filename){//////////加載xml文件

    Document document = null; 

       try{

       DocumentBuilderFactory   factory = DocumentBuilderFactory.newInstance();    

           DocumentBuilder builder=factory.newDocumentBuilder();    

           document=builder.parse(new File(filename));    

           document.normalize(); 

       }catch (Exception ex){

           ex.printStackTrace(); 

       }   

       return document; 

    }

     

    public boolean doc2XmlFile(Document document,File targetFile){ ///////回寫xml文件

    boolean flag = true; 

       try{

       TransformerFactory tFactory = TransformerFactory.newInstance();    

           Transformer transformer = tFactory.newTransformer();  

           DOMSource source = new DOMSource(document);  

           StreamResult result = new StreamResult(targetFile.toURI().getPath());

           transformer.transform(source, result);  

       }catch(Exception ex){ 

           flag = false; 

           ex.printStackTrace(); 

       } 

       return flag;       

    }

    String void function(){///////////程序入口

     

    String rootPath=ServletActionContext.getServletContext().getRealPath("/excelTemplate")+"\\";

    try{

    Document document=loadXML(rootPath+"projectModel.xml");

    Element root = document.getDocumentElement();

    NodeList rootList=root.getChildNodes();

    Node bodyNode=null;///////w:body

    for(int i=0;i<rootList.getLength();i++){////////找到<w:body>節點

    bodyNode=rootList.item(i);

    if("w:body".equals(bodyNode.getNodeName())){

    break;

    }

    }

    NodeList nodeList=bodyNode.getChildNodes();

    for(int i=0;i<nodeList.getLength();i++){

    Node node=nodeList.item(i);

    if("w:tbl".equals(node.getNodeName())){

    dealWithTableNode(document,node);

    }else if("w:p".equals(node.getNodeName())){

    dealWithWPNode(document,node);

    }

     

    }

    File destFile = File.createTempFile("project", ".xml");

    doc2XmlFile(document,destFile);///////回寫

    inputStream = new FileInputStream(destFile);/////////生成流,用于下載

    fileName=URLEncoder.encode(project.getProjectName(),"utf-8")+".doc";

    }catch(Exception e){

    e.printStackTrace();

    }

     

    }

    注意:

    1、在解析編輯xml文件的時候一定好看好節點的位置,比如一般的文本內容的話可能是在<w:p>節點下的<w:r>節點下的<w:t>里設置,使用的是getTextContent()方法來獲取它的內容,setTextContent()來設置它的參數

    2、對于圖片如何插入呢?首先最好在模板中插入一張圖片,主要用于定下圖片的那些格式,然后圖片必須用java轉成base64的字符串,這里也提供一個方法:

     

    private String toBASE64codeFile(File file){

    String codeString="";

    try{

    FileInputStream fis=new FileInputStream(file);

    BASE64Encoder encoder=new BASE64Encoder();

    byte[] b=new byte[228];

    int count=-1,n=0;

    while((count=fis.read(b))!=-1){

    codeString+=encoder.encode(b);

    }

    return codeString;

    }catch(Exception e){

    e.printStackTrace();

    return "";

    }

    }

    然后找到<w:pict>節點:一般如果圖片是在table里的話,該節點就是在<w:tbl>-<w:tr>-<w:tc>-<w:p>-<w:r>節點下面,不在table里的話就是:<w:p>-<w:r>,建議仿照用IE打開的xml對照一下。然后將該節點下的<w:binData>的內容置成你所要插入的圖片的base64碼即可。

    posted @ 2013-03-06 13:30 yuhaibo736 閱讀(613) | 評論 (0)編輯 收藏

    將幾個word文件合并到一個word文件,需要下載jacob-1.17-M2.zip,將壓縮文件內的jacob-1.17-M2-x64.dll放到windows/system32下,將jacob.jar放到項目中
    public static void main(String[] args) {
       List list  = new ArrayList();
       String file1= "D:\\file1.doc";
       String file2= "D:\\file2.doc";
       String file3= "D:\\file3.doc";
       list.add(file1);
       list.add(file2);
       list.add(file3);
       uniteDoc(list,"d:\\file.doc");
     }
     public static void uniteDoc(List fileList, String savepaths) {
      if (fileList.size() == 0 || fileList == null) {
       return;
      }
      //打開word
      ActiveXComponent app = new ActiveXComponent("Word.Application");//啟動word
      try {
       // 設置word不可見
       app.setProperty("Visible", new Variant(false));
       //獲得documents對象
       Object docs = app.getProperty("Documents").toDispatch();
       //打開第一個文件
       Object doc = Dispatch
                    .invoke(
                            (Dispatch) docs,
                            "Open",
                            Dispatch.Method,
                            new Object[] { (String) fileList.get(0),
                                    new Variant(false), new Variant(true) },
                            new int[3]).toDispatch();
       //追加文件
       for (int i = 1; i < fileList.size(); i++) {
        Dispatch.invoke(app.getProperty("Selection").toDispatch(),
                        "insertFile", Dispatch.Method, new Object[] {
                                (String) fileList.get(i), "",
                                new Variant(false), new Variant(false),
                                new Variant(false) }, new int[3]);
       }
       //保存新的word文件
       Dispatch.invoke((Dispatch) doc, "SaveAs", Dispatch.Method,
                    new Object[] { savepaths, new Variant(1) }, new int[3]);
       Variant f = new Variant(false);
       Dispatch.call((Dispatch) doc, "Close", f);
      } catch (Exception e) {
       throw new RuntimeException("合并word文件出錯.原因:" + e);
      } finally {
       app.invoke("Quit", new Variant[] {});
      }
     }


    posted @ 2013-03-06 13:20 yuhaibo736 閱讀(1242) | 評論 (0)編輯 收藏


    package com.cbd.dk.test;

    import java.util.ListIterator;
    import java.util.Stack;

    public class Test {

     private String src;

     public Test(String src) {
      this.src = src;
     }
     public double getResult() {
      String postfix = getPostfix();
      Stack<String> stk = new Stack<String>();
      //System.out.println(postfix);
      String parts[] = postfix.split(" +");
      double result=0;
      for(int i=0; i<parts.length; i++){
       char tmp = parts[i].charAt(0);
       if(!isOperator(tmp)){
        stk.push(parts[i]);
       }else{
        double a = Double.parseDouble(stk.pop());
        double b = Double.parseDouble(stk.pop());
        result = calculate(b,a,tmp);
        stk.push(String.valueOf(result));
       }
      }
      return result;
     }


     /**
      * test if the character is an operator,such +,-,*,/
      * @param op  the character to test
      * @return  true if op is an operator otherwise false
      */
     private boolean isOperator(char op){
      return (op=='+'||op=='-'||op=='*'||op=='/');
     }


     /**
      * calculate an expression such (a op b)
      * @param a  number 1
      * @param b  number 2
      * @param op the operator
      * @return  (double)(a op b)
      */
     public double calculate(double a, double b, char op) {
      switch (op) {
       case '+':
        return a + b;
       case '-':
        return a - b;
       case '*':
        return a * b;
       case '/':
        return a / b;
      }
      return -1;
     }


     /**
      * convert the suffix to postfix
      * @return the postfix as a string
      */
     private String getPostfix() {
      Stack<String> stk = new Stack<String>();
      String postfix = new String();
      char op;
      int i = 0;
      while (i < src.length()) {
       if (Character.isDigit(src.charAt(i))||src.charAt(i)=='.') {
        postfix += " ";
        do {
         postfix += src.charAt(i++);
        } while ((i < src.length()) && (Character.isDigit(src.charAt(i))));
        postfix += " ";
       }else {
        switch (op = src.charAt(i++)) {
         case '(':
          stk.push("(");
          break;
         case ')':
          while (stk.peek() != "(") {
           String tmp = stk.pop();
           postfix += tmp;
           if(tmp.length()==1 && isOperator(tmp.charAt(0)))
            postfix += " ";
          }
          stk.pop();
          postfix += " ";
          break;
         case '+':
         case '-':
          while ((!stk.empty()) && (stk.peek() != "(")) {
           postfix += stk.pop()+" ";
          }
          stk.push(new Character(op).toString());
          break;
         case '*':
         case '/':
          while ((!stk.empty()) && ((stk.peek() == "*") || (stk.peek() == "/"))) {
           postfix += stk.pop()+" ";
          }
          stk.push(new Character(op).toString());
          break;
        }
       }
      }
      ListIterator it = stk.listIterator(stk.size());
      while (it.hasPrevious())
       postfix += it.previous() + " ";
      return postfix.trim().replaceAll(" +\\.",".");
     }

     /**
      * main function
      * @param args
      */
     public static void main(String args[]) {
      //System.out.println(new Test("((1.5+6.000)*9+9.36)*(8-8*8+8*7)").getResult());
      System.out.println(new Test("(2+(3*2)/2)").getResult());
     }
    }

    posted @ 2012-12-11 16:24 yuhaibo736 閱讀(1134) | 評論 (0)編輯 收藏

    WITH CTE AS
    (
    SELECT OBJ_VW_ID,NODE_CODE ,P_NODE_CODE,NODE_TYP ,NODE_CAP,OBJ_VW_ENG_NAME,SN,ICON_TYP,rn=cast(NODE_CODE  as varchar(max)),level = 1 FROM DSK_OBJ_VW_DISP  WHERE NODE_CODE in (select NODE_CODE from DSK_OBJ_VW_DISP where P_NODE_CODE='2')
    UNION ALL
    SELECT T.OBJ_VW_ID,T.NODE_CODE,T.P_NODE_CODE,T.NODE_TYP,T.NODE_CAP,T.OBJ_VW_ENG_NAME,T.SN,T.ICON_TYP,rn=rn+cast(T.NODE_CODE AS VARCHAR(MAX)), level=level+1 FROM DSK_OBJ_VW_DISP T,CTE WHERE CTE.NODE_CODE=T.P_NODE_CODE
    )
    SELECT OBJ_VW_ID,NODE_CODE ,P_NODE_CODE,NODE_TYP,NODE_CAP,OBJ_VW_ENG_NAME,SN,ICON_TYP,rn,level FROM CTE  ORDER BY rn

    posted @ 2012-10-23 15:04 yuhaibo736 閱讀(722) | 評論 (0)編輯 收藏

    package test;

    import org.apache.commons.lang3.ArrayUtils;
    import org.apache.commons.lang3.StringUtils;

    public class TestStringUtils {
     
     public static void main(String[] args) {
      // 空字符串檢查
      String t1_1 = "";
      String t1_2 = "\n\n\t";
      String t1_3 = null;
      String t1_4 = "Test";
      System.out.println("t1_1 blank? " + StringUtils.isBlank(t1_1));
      System.out.println("t1_2 blank? " + StringUtils.isBlank(t1_2));
      System.out.println("t1_3 blank? " + StringUtils.isBlank(t1_3));
      System.out.println("t1_4 blank? " + StringUtils.isBlank(t1_4));
      // 清除空白字符
      String t2_1 = "\t";
      String t2_2 = "  A  Test  ";
      String t2_3 = null;
      System.out.println("t2_1 trimToNull: " + StringUtils.trimToNull(t2_1));
      System.out.println("t2_2 trimToNull: " + StringUtils.trimToNull(t2_2));
      System.out.println("t2_3 trimToNull: " + StringUtils.trimToNull(t2_3));
      System.out.println("t2_1 trim: " + StringUtils.trim(t2_1));
      System.out.println("t2_2 trim: " + StringUtils.trim(t2_2));
      System.out.println("t2_3 trim: " + StringUtils.trim(t2_3));
      // 取得字符串的縮寫
      String t3_1 = "This is a test of the abbreviation.";
      String t3_2 = "Test";
      System.out.println(StringUtils.abbreviate(t3_1, 15));
      System.out.println(StringUtils.abbreviate(t3_1, 5, 15));
      System.out.println(StringUtils.abbreviate(t3_2, 10));
      // 劈分字符串
      String t4_1 = "A b,c.d|e";
      String t4_2 = "Pharmacy, basketball funky";
      String[] array1 = StringUtils.split(t4_1, " ,.|");
      String[] array2 = StringUtils.split(t4_2, " ,", 2);
      System.out.println(ArrayUtils.toString(array1));
      System.out.println(ArrayUtils.toString(array2));
      // 查找嵌套字符串
      String t5_1 = "ABC1234ABC4567";
      System.out.println(StringUtils.substringBetween(t5_1, "1234", "4567"));
      System.out.println(StringUtils.substringBetween(t5_1, "12345", "4567"));
      // 去除尾部換行符
      String t6_1 = "Hello\n";
      System.out.println(StringUtils.chomp(t6_1));
      String t6_2 = "Another test\r\n";
      System.out.println(StringUtils.chomp(t6_2));
      // 重復字符串
      System.out.println(StringUtils.repeat("*", 10));
      System.out.println(StringUtils.repeat("China ", 5));
      // 顛倒字符串
      System.out.println(StringUtils.reverse("ABCDE"));
      // 判斷字符串內容的類型
      String t7_1 = "Virginia";
      System.out.println("Is state number? " + StringUtils.isNumeric(t7_1));// 全由數字組成
      System.out.println("Is state alpha? " + StringUtils.isAlpha(t7_1));// 全由字母組成
      System.out.println("Is state alphanumeric? " + StringUtils.isAlphanumeric(t7_1));// 全由數字或數字組成
      System.out.println("Is state alphaspace? " + StringUtils.isAlphaSpace(t7_1));// 全由字母或空格組成
      // 取得某字符串在另一字符串中出現的次數
      System.out.println(StringUtils.countMatches("Chinese People", "e"));
      // 部分截取字符串
      String t8_1 = " 25 * (30,40) [50,60] | 30";
      System.out.print("N0: " + StringUtils.substringBeforeLast(t8_1, "*"));
      System.out.print(", N1: " + StringUtils.substringBetween(t8_1, "(", ","));
      System.out.print(", N2: " + StringUtils.substringBetween(t8_1, ",", ")"));
      System.out.print(", N3: " + StringUtils.substringBetween(t8_1, "[", ","));
      System.out.print(", N4: " + StringUtils.substringBetween(t8_1, ",", "]"));
      System.out.print(", N5: " + StringUtils.substringAfterLast(t8_1, "|"));
     }

    }

    posted @ 2012-08-30 11:02 yuhaibo736 閱讀(573) | 評論 (0)編輯 收藏

    依賴包 json-lib-2.2.3-jdk13.jar、dom4j-1.6.1.jar

     

    package com.shine.framework.core.util;
    import java.io.ByteArrayOutputStream;
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.Iterator;
    import java.util.List;
    import java.util.Map;
    import net.sf.json.JSON;
    import net.sf.json.JSONSerializer;
    import net.sf.json.xml.XMLSerializer;
    import org.dom4j.Document;
    import org.dom4j.DocumentHelper;
    import org.dom4j.Element;
    import org.dom4j.io.OutputFormat;
    import org.dom4j.io.XMLWriter;
    /**
    * common xml conver utility
    *
    * @author viruscodecn@gmail.com
    * @version Framework 2010.10.26
    */
    public class XmlConverUtil {
    /**
    * map to xml xml <node><key label="key1">value1</key><key
    * label="key2">value2</key>......</node>
    *
    * @param map
    * @return
    */
    public static String maptoXml(Map map) {
    Document document = DocumentHelper.createDocument();
    Element nodeElement = document.addElement("node");
    for (Object obj : map.keySet()) {
    Element keyElement = nodeElement.addElement("key");
    keyElement.addAttribute("label", String.valueOf(obj));
    keyElement.setText(String.valueOf(map.get(obj)));
    }
    return doc2String(document);
    }
    /**
    * list to xml xml <nodes><node><key label="key1">value1</key><key
    * label="key2">value2</key>......</node><node><key
    * label="key1">value1</key><key
    * label="key2">value2</key>......</node></nodes>
    *
    * @param list
    * @return
    */
    public static String listtoXml(List list) {
    Document document = DocumentHelper.createDocument();
    Element nodesElement = document.addElement("nodes");
    for (Object o : list) {
    Element nodeElement = nodesElement.addElement("node");
    for (Object obj : ((Map) o).keySet()) {
    Element keyElement = nodeElement.addElement("key");
    keyElement.addAttribute("label", String.valueOf(obj));
    keyElement.setText(String.valueOf(((Map) o).get(obj)));
    }
    }
    return doc2String(document);
    }
    /**
    * json to xml {"node":{"key":{"@label":"key1","#text":"value1"}}} conver
    * <o><node class="object"><key class="object"
    * label="key1">value1</key></node></o>
    *
    * @param json
    * @return
    */
    public static String jsontoXml(String json) {
    try {
    XMLSerializer serializer = new XMLSerializer();
    JSON jsonObject = JSONSerializer.toJSON(json);
    return serializer.write(jsonObject);
    } catch (Exception e) {
    e.printStackTrace();
    }
    return null;
    }
    /**
    * xml to map xml <node><key label="key1">value1</key><key
    * label="key2">value2</key>......</node>
    *
    * @param xml
    * @return
    */
    public static Map xmltoMap(String xml) {
    try {
    Map map = new HashMap();
    Document document = DocumentHelper.parseText(xml);
    Element nodeElement = document.getRootElement();
    List node = nodeElement.elements();
    for (Iterator it = node.iterator(); it.hasNext();) {
    Element elm = (Element) it.next();
    map.put(elm.attributeValue("label"), elm.getText());
    elm = null;
    }
    node = null;
    nodeElement = null;
    document = null;
    return map;
    } catch (Exception e) {
    e.printStackTrace();
    }
    return null;
    }
    /**
    * xml to list xml <nodes><node><key label="key1">value1</key><key
    * label="key2">value2</key>......</node><node><key
    * label="key1">value1</key><key
    * label="key2">value2</key>......</node></nodes>
    *
    * @param xml
    * @return
    */
    public static List xmltoList(String xml) {
    try {
    List<Map> list = new ArrayList<Map>();
    Document document = DocumentHelper.parseText(xml);
    Element nodesElement = document.getRootElement();
    List nodes = nodesElement.elements();
    for (Iterator its = nodes.iterator(); its.hasNext();) {
    Element nodeElement = (Element) its.next();
    Map map = xmltoMap(nodeElement.asXML());
    list.add(map);
    map = null;
    }
    nodes = null;
    nodesElement = null;
    document = null;
    return list;
    } catch (Exception e) {
    e.printStackTrace();
    }
    return null;
    }
    /**
    * xml to json <node><key label="key1">value1</key></node> 轉化為
    * {"key":{"@label":"key1","#text":"value1"}}
    *
    * @param xml
    * @return
    */
    public static String xmltoJson(String xml) {
    XMLSerializer xmlSerializer = new XMLSerializer();
    return xmlSerializer.read(xml).toString();
    }
    /**
    *
    * @param document
    * @return
    */
    public static String doc2String(Document document) {
    String s = "";
    try {
    // 使用輸出流來進行轉化
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    // 使用UTF-8編碼
    OutputFormat format = new OutputFormat(" ", true, "UTF-8");
    XMLWriter writer = new XMLWriter(out, format);
    writer.write(document);
    s = out.toString("UTF-8");
    } catch (Exception ex) {
    ex.printStackTrace();
    }
    return s;
    }
    public static void main(String args[]) {
    XmlConverUtil util = new XmlConverUtil();
    String xml = "{/"node/":{/"key/":{/"@lable/":/"key1/",/"#text/":/"value1/"}}}";
    System.out.println(util.jsontoXml(xml));
    }
    }

    posted @ 2012-08-28 15:16 yuhaibo736 閱讀(2018) | 評論 (0)編輯 收藏

    commons-beanutils-1.8.0.jar不加這個包
    java.lang.NoClassDefFoundError: org/apache/commons/beanutils/DynaBean
    commons-collections.jar 不加這個包
    java.lang.NoClassDefFoundError: org/apache/commons/collections/map/ListOrderedMap
    commons-lang-2.4.jar不加這個包
    java.lang.NoClassDefFoundError: org/apache/commons/lang/exception/NestableRuntimeException
    commons-logging-1.1.1.jar不加這個包
    java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
    ezmorph-1.0.4.jar不加這個包
    java.lang.NoClassDefFoundError: net/sf/ezmorph/Morpher
    json-lib-2.3-jdk15.jar不加這個包
    java.lang.NoClassDefFoundError: net/sf/json/JSONObject
    相應jar包可到網上下載!
    實例:
    import java.util.ArrayList;
    import java.util.List;

    import net.sf.json.JSONArray;

    public class JsonTest {

    /**
    * @param args
    */
    public static void main(String[] args) throws Exception{
    boolean[] boolArray = new boolean[]{true,false,true}; 
    JSONArray jsonArray = JSONArray.fromObject( boolArray ); 
    System.out.println( jsonArray );

    List list = new ArrayList(); 
    list.add( "first" ); 
    list.add( "second" ); 
    JSONArray jsonArray2 = JSONArray.fromObject( list ); 
    System.out.println( jsonArray2 );
    }
    }

    posted @ 2012-08-15 14:04 yuhaibo736 閱讀(4684) | 評論 (2)編輯 收藏

      1.將Image圖像文件存入到數據庫中 我們知道數據庫里的Image類型的數據是"二進制數據",因此必須將圖像文件轉換成字節數組才能存入數據庫中。

      //根據文件名(完全路徑)

      public byte[] SetImageToByteArray(string fileName)

      { FileStream fs = new FileStream(fileName, FileMode.Open);

      int streamLength = (int)fs.Length; byte[] image = new byte[streamLength];

      fs.Read(image, 0, streamLength);

      fs.Close();

      return image; }

      //另外,在ASP.NET中通過FileUpload控件得到的圖像文件可以通過以下方法

      public byte[]

      SetImageToByteArray(FileUpload FileUpload1)

      { Stream stream = FileUpload1.PostedFile.InputStream;

      byte[] photo = new byte[FileUpload1.PostedFile.ContentLength];

      stream.Read(photo, 0, FileUpload1.PostedFile.ContentLength);

      stream.Close();

      return photo;

      }

      2.從SQL Server數據庫讀取Image類型的數據,并轉換成bytes[]或Image圖像文件

      //要使用SqlDataReader要加載using System.Data.SqlClient命名空間

      //將數據庫中的Image類型轉換成byte[] public byte[] SetImage(SqlDataReader reader)

      { return (byte[])reader["Image"];//Image為數據庫中存放Image類型字段 }

      //將byte[]轉換成Image圖像類型 //加載以下命名空間using System.Drawing;/using System.IO;

      using System.Data.SqlClient;*/ public Image SetByteToImage(byte[] mybyte)

      { Image image; MemoryStream mymemorystream = new MemoryStream(mybyte,0, mybyte.Length);

      image = Image.FromStream(mymemorystream);

      return image;

      }

    posted @ 2012-08-14 13:07 yuhaibo736 閱讀(317) | 評論 (0)編輯 收藏

    僅列出標題
    共5頁: 上一頁 1 2 3 4 5 下一頁 
    主站蜘蛛池模板: 亚洲av片在线观看| 亚洲综合在线成人一区| 免费国产高清毛不卡片基地| 国产乱子伦片免费观看中字| 亚洲熟妇无码八V在线播放| 性xxxx视频播放免费| 含羞草国产亚洲精品岁国产精品 | 亚洲另类无码专区首页| 蜜桃视频在线观看免费网址入口| 亚洲一区在线免费观看| 女人被男人躁的女爽免费视频 | 亚洲伊人久久大香线蕉| 丁香花免费高清视频完整版| 亚洲人成网站在线播放2019| 国产91在线免费| 国产精品极品美女自在线观看免费 | 69成人免费视频| 亚洲sm另类一区二区三区| 免费a级毛片无码a∨性按摩| 九九全国免费视频| 亚洲av日韩av无码| 成人免费福利电影| ww在线观视频免费观看w| 精品国产综合成人亚洲区| 久久午夜免费鲁丝片| 精品亚洲AV无码一区二区| 国产v片免费播放| AAA日本高清在线播放免费观看| 亚洲欧洲日产国码www| 免费大学生国产在线观看p| 免费无码又爽又刺激高潮软件| 亚洲一区二区三区久久久久| 国产免费卡一卡三卡乱码| 国产拍拍拍无码视频免费| 99久久国产亚洲综合精品| 国产成人高清亚洲| 免费观看激色视频网站bd| 国产精品亚洲一区二区无码| 亚洲欧洲国产精品你懂的| 国产免费无遮挡精品视频| 久久午夜无码免费|