❶ 在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解析 ==