❶ 在xml文件中插入sql语句
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
Response.ContentType="application/xml"
Response.Charset="utf-8"
response.cachecontrol="no-cache"
response.addHeader "pragma","no-cache"
response.expires=-1
response.expiresAbsolute=now-1
db="file.mdb" '数据库路径,相对路径
set conn = server.CreateObject("adodb.connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(db)
Response.Write("<?xml version=""1.0"" encoding=""utf-8""?>")
set rs=Server.CreateObject("adodb.recordset")
rs.open "SELECT * FROM [file]",conn,1,1
if rs.Eof and rs.Bof then
Response.Write("<vcaster>")
Response.Write ("<item item_url=""no file"" item_title=""no file"">")
Response.Write("</item>")
Response.Write ("</vcaster>")
else
Response.Write("<vcaster>")
do while Not rs.Eof
Response.Write ("<item item_url="""&rs("fileurl")&""" item_title="""&rs("name")&""">")
Response.Write("</item>")
if rs.Eof then
Exit do
End if
rs.MoveNext
Loop
Response.Write ("</vcaster>")
End if
rs.Close
Set rs=Nothing
conn.Close
Set conn=Nothing
%>
❷ Java中用sql语句将xml文件导入 Access 数据库,急用!谢谢
sql语句好像没这导入的功能吧,插入那是人工的方法,的自己写,不过数据库好像都可以使用客户端进行导入的;想mysql就有Natcat for mysql 可以直接导入xml文件到数据库的,好像Access要写程序导入。
❸ xml在java与SQL的交互过程中起什么作用
用jdbc的话用不着xml(除非把用户名等信息存入xml中)就可以操作sql了,如果是java访问数据库要用到xml的话,那也就是hibernate了,那样的话,xml的作用就是把 类的属性和数据库中的字段对应起来,也就是告诉hibernate类的哪个属性对应着数据库中的哪个字段,当存入一个对象时,hibernate就回把对象的属性按照xml的对应信息分别存入数据库了
❹ Java MyBatis SQL语句
你不是已经看到了吗,你加的WHERE 和你的 include ref有冲突的,如果你要实现
只要包一层table 出来就好了,以你的 Byconitions为模板:
select * from (select * from user_trade_recode where trade_type=1 and trade_kind=1)
<if test='…………'>
………………
</if>
order by id desc
❺ 将sql语句写入xml文件里,怎样写一个java类去调用xml里面的sql语句
j建议你去先自己学一个星期Hibernate
❻ java里面.xml中的sql语句是否也要用驼峰命名
XML的sql命名的话 就随意了。通常都是 文件名 模块名 功能名
比如 userloginxml_userinfo_selectpassword
❼ JAVA编程实现xml与数据库之间的交互。
1.网上找Castor或者jaxb的包,看下例子就行了
这包是完成对象到xml的一中映射,生产xml文件,或者xml解析成对象
2.自己定义一个映射规则,自己写出处理程序完成,用dom4j这个包不错
具体来说,就是数据库读取数据封装成一个个对象或者一个集合,完成数据到对象的关系映射,
然后对象转化到xml,完成对象到xml的映射
❽ Java里的mapper.xml语句 求各位哥哥翻译成SQL语句 谢谢!!
这里有if判断,生成的sql也随条件,不是固定的。
如果没有 if 生成的SQL是这样的
select uc_user_work.busy_type as busyType,count( uc_user_work.busy_type ) as num,
uc_perm.perm_name as permName
from uc_user_work left outer join uc_perm on uc_user_work.busy_type=uc_perm.perm_id
left outer join uc_work on uc_work.work_id=uc_user_work.work_id
where uc_user_work.uc_id = #{ucId,jdbcType=INTEGER} and uc_work.status!=3
and uc_work.status!=4
and uc_user_work.bind_status != #{bindStatus,jdbcType=INTEGER}
and uc_user_work.status != #{status,jdbcType=INTEGER} .....等等后面的就不写了
#{ }里面的值是你传过去的。
<where></where> 标签起始就相当于对标签里面的内容进行条件选择 相当于SQL里的 where ...and... 。你写的这个<if></if>标签里面的and 可以去掉,应为本身就在where标签里了
❾ Java 操作xml有那种能像操作数据的sql语句那样操作的么有的话,请详细解释下,或者留个链接,多谢..
可以用DOM(文件对象模型)来生成或者解析xml文件。
给你个代码例子,看明白了就差不多了:
import java.io.FileInputStream; import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
/** ** DOM生成与解析XML文档 */
public class JavaTestXMLFile{
private Document document;
private String fileName;
public void init()
{
try
{
DocumentBuilderFactory factory = DocumentBuilderFactory .newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
this.document = builder.newDocument();
}
catch (ParserConfigurationException e)
{
System.out.println(e.getMessage());
}
}
public void createXml(String fileName)
{
Element root = this.document.createElement("employees");
this.document.appendChild(root);
Element employee = this.document.createElement("employee");
Element name = this.document.createElement("name");
name.appendChild(this.document.createTextNode("employee1"));
employee.appendChild(name);
Element sex = this.document.createElement("sex");
sex.appendChild(this.document.createTextNode("m"));
employee.appendChild(sex);
Element age = this.document.createElement("age");
age.appendChild(this.document.createTextNode("25"));
employee.appendChild(age); root.appendChild(employee);
TransformerFactory tf = TransformerFactory.newInstance();
try
{
Transformer transformer = tf.newTransformer();
DOMSource source = new DOMSource(document);
transformer.setOutputProperty(OutputKeys.ENCODING, "gb2312");
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
PrintWriter pw = new PrintWriter(new FileOutputStream(fileName));
StreamResult result = new StreamResult(pw);
transformer.transform(source, result);
System.out.println("生成XML文件成功!");
}
catch ( e)
{
System.out.println(e.getMessage());
}
catch (IllegalArgumentException e)
{
System.out.println(e.getMessage());
}
catch (FileNotFoundException e)
{
System.out.println(e.getMessage());
}
catch (TransformerException e)
{
System.out.println(e.getMessage());
}
}
public void parserXml(String fileName)
{
try
{
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document document = db.parse(fileName);
NodeList employees = document.getChildNodes();
for (int i = 0; i < employees.getLength(); i++)
{
Node employee = employees.item(i);
NodeList employeeInfo = employee.getChildNodes();
for (int j = 0; j < employeeInfo.getLength(); j++)
{
Node node = employeeInfo.item(j);
NodeList employeeMeta = node.getChildNodes();
for (int k = 0; k < employeeMeta.getLength(); k++)
{
System.out.println(employeeMeta.item(k).getNodeName() + ":" + employeeMeta.item(k).getTextContent());
}
}
}
System.out.println("解析完毕");
}
catch (FileNotFoundException e)
{
System.out.println(e.getMessage());
}
catch (ParserConfigurationException e)
{
System.out.println(e.getMessage());
}
catch (SAXException e)
{
System.out.println(e.getMessage());
}
catch (IOException e)
{
System.out.println(e.getMessage());
}
}
public static void main(String[] args) {
JavaTestXMLFile myJavaTestXMLFile=new JavaTestXMLFile();
myJavaTestXMLFile.init();
myJavaTestXMLFile.createXml("DomCreateXml.xml");
myJavaTestXMLFile.parserXml("DomCreateXml.xml");
}
}
❿ java中如何通过xml配置文件来操作sql语句
xml本来就是为定义数据服务的,在解析xml的时候,可以按照预定义的规则进行解析。具体的格式可以由自己来定义,但是这种格式涵盖的内容必须包含构建这个表(实现某一数据结构)的必须条件。 这样定义好xml之后,在解析的时候可以根据给定规则,解析出具体的某个表(某一数据结构)。 对于你的这段xml也就是这样的。具体的解析方法,可以看dom解析 sax解析 ==