hgbdelphi
asked on
how can i load data from xml with no limit???
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.readXm l(baseXmlU rl);
rootElement = document.getRootElement();
}
public void readXmlConfig(){
Element tempElement=null;
System.out.println("jbas-c onfig:"+ro otElement. getName()) ;
Element classElement=rootElement.e lement("cl ass");
System.out.println("name:" +classElem ent.attrib uteValue(" name"));
Element methodElement=classElement .element(" method");
System.out.println("name:" +methodEle ment.attri buteValue( "name"));
Element itemElement=methodElement. element("i tem");
System.out.println("name:" +itemEleme nt.attribu teValue("n ame"));
System.out.println("outcom e"+itemEle ment.attri buteValue( "outcome") );
Element sqlElement=itemElement.ele ment("sql" );
System.out.println("sqlVal ue:"+sqlEl ement.getT ext());
Element paramElement=itemElement.e lement("pa ram");
for(int i=0;i<paramElement.element s().size() ;i++){
System.out.println("param: "+((Elemen t)paramEle ment.eleme nts().get( i)).getTex t());
}
}
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!
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
document=DomXmlUtil.readXm
rootElement = document.getRootElement();
}
public void readXmlConfig(){
Element tempElement=null;
System.out.println("jbas-c
Element classElement=rootElement.e
System.out.println("name:"
Element methodElement=classElement
System.out.println("name:"
Element itemElement=methodElement.
System.out.println("name:"
System.out.println("outcom
Element sqlElement=itemElement.ele
System.out.println("sqlVal
Element paramElement=itemElement.e
for(int i=0;i<paramElement.element
System.out.println("param:
}
}
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.
<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!
wrap the sql in a CDATA block.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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!!!
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!!!
ASKER
hi,objects
can help me another question?thanks very much.
public class TPersonBean {
public TPerson getPersonByName(String name){
myclass.doMethod("TPersonB ean","getP ersonByNam e");
}
}
i want this
public class TPersonBean {
public TPerson getPersonByName(String name){
myclass.doMethod(this.getC lass().get Name(),xxx xxxxxxxxxx xxxxx???);
}
}
can help me another question?thanks very much.
public class TPersonBean {
public TPerson getPersonByName(String name){
myclass.doMethod("TPersonB
}
}
i want this
public class TPersonBean {
public TPerson getPersonByName(String name){
myclass.doMethod(this.getC
}
}
unless you pass the method name, you'll need to specify it explicitly:
public class TPersonBean {
public TPerson getPersonByName(String name){
myclass.doMethod(this.getC lass().get Name(), "getPersonByName");
}
}
you'll probably also want top pass the actual name also
public class TPersonBean {
public TPerson getPersonByName(String name){
myclass.doMethod(this.getC lass().get Name(), "getPersonByName", name);
}
}
public class TPersonBean {
public TPerson getPersonByName(String name){
myclass.doMethod(this.getC
}
}
you'll probably also want top pass the actual name also
public class TPersonBean {
public TPerson getPersonByName(String name){
myclass.doMethod(this.getC
}
}
ASKER
oh,i see
thank for your help again.
Best regard for Object!
thank for your help again.
Best regard for Object!
:)