?
Solved

how can i load data from xml with no limit???

Posted on 2005-04-21
7
Medium Priority
?
207 Views
Last Modified: 2010-03-31
hi,experts
  i want load sql statement and parament from my xml file,and combination a sql statement to execute.this is my base code.  

public class BaseXSql {

    String baseXmlUrl="";
    Document document=null;
    Element rootElement=null;
   
    public BaseXSql(){
          baseXmlUrl="c:\\jbasConfig.xml";
          document=DomXmlUtil.readXml(baseXmlUrl);  
          rootElement = document.getRootElement();
    }
   
    public void readXmlConfig(){
        Element tempElement=null;
        System.out.println("jbas-config:"+rootElement.getName());

        Element classElement=rootElement.element("class");
        System.out.println("name:"+classElement.attributeValue("name"));
     
        Element methodElement=classElement.element("method");
        System.out.println("name:"+methodElement.attributeValue("name"));

        Element itemElement=methodElement.element("item");
        System.out.println("name:"+itemElement.attributeValue("name"));
        System.out.println("outcome"+itemElement.attributeValue("outcome"));
       
        Element sqlElement=itemElement.element("sql");

        System.out.println("sqlValue:"+sqlElement.getText());
       
        Element paramElement=itemElement.element("param");
        for(int i=0;i<paramElement.elements().size();i++){
            System.out.println("param:"+((Element)paramElement.elements().get(i)).getText());  
        }

    }
   
   public static void main(String[] args){
       BaseXSql baseXSql=new BaseXSql();
       baseXSql.readXmlConfig();
   }
   
and this is my xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<jbas-config>
   <class name="com.jbas.track.user.LogonBean">
       <method name="isLogin">
           <item name="sql1" outcome="int">
                        <sql>
                   select 1 from TPERSON where LOGINNAME=? and PASSWD=? and Deleted<>'N'
                        </sql>
                        <param>
                           <type>String</type>
                           <type>String</type>
                        </param>
                  </item>

         </method>
   </class>
   


</jbas-config>


but in xml not support:<>'N' ,how can i do it ????

and experts can tell me where or how i can learn about this action:define some sql and parameter statement in xml,and in java get this value and combination a new sql statement to execute and can return ArrayList or another.i think if i do it ,when i want to change sql statement,i will not change java code ,and change xml config only.

thanks!
0
Comment
Question by:hgbdelphi
  • 4
  • 3
7 Comments
 
LVL 92

Expert Comment

by:objects
ID: 13831464
wrap the sql in a CDATA block.
0
 
LVL 92

Accepted Solution

by:
objects earned 1200 total points
ID: 13831467
0
 

Author Comment

by:hgbdelphi
ID: 13831523
thanks for objects,i solve it ,about

and experts can tell me where or how i can learn about this action:define some sql and parameter statement in xml,and in java get this value and combination a new sql statement to execute and can return ArrayList or another.i think if i do it ,when i want to change sql statement,i will not change java code ,and change xml config only


can give me some adive!

thanks very much!!!
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:hgbdelphi
ID: 13839678
hi,objects
  can help me another question?thanks very much.

public class TPersonBean {
    public TPerson getPersonByName(String name){
                myclass.doMethod("TPersonBean","getPersonByName");
    }
}

i want this

public class TPersonBean {
    public TPerson getPersonByName(String name){
                myclass.doMethod(this.getClass().getName(),xxxxxxxxxxxxxxxxxx???);
    }
}

0
 
LVL 92

Expert Comment

by:objects
ID: 13839717
unless you pass the method name, you'll need to specify it explicitly:

public class TPersonBean {
    public TPerson getPersonByName(String name){
                myclass.doMethod(this.getClass().getName(), "getPersonByName");
    }
}

you'll probably also want top pass the actual name also

public class TPersonBean {
    public TPerson getPersonByName(String name){
                myclass.doMethod(this.getClass().getName(), "getPersonByName", name);
    }
}
0
 

Author Comment

by:hgbdelphi
ID: 13839756
oh,i see
  thank for your help again.

Best regard for Object!
0
 
LVL 92

Expert Comment

by:objects
ID: 13862823
:)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses
Course of the Month17 days, 8 hours left to enroll

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question