简体   繁体   English

使用Java从SQL数据库创建XML文件

[英]Creating a XML file from a SQL database using Java

There seems to be no information on this anywhere. 似乎任何地方都没有任何信息。

In anycase, I've been asked to create a Java program that takes information from a SQL database and creates a XML file. 无论如何,都要求我创建一个Java程序,该程序从SQL数据库获取信息并创建XML文件。

I can see I'm going to be using the DocumentBuilder tool. 我可以看到我将要使用DocumentBuilder工具。 However, I'm not sure exactly how to implement or how to begin, considering it's SQL. 但是,考虑到它是SQL,我不确定确切如何实现或如何开始。

The Database has not been created yet. 数据库尚未创建。

Thanks in advance. 提前致谢。

you can use JAXB concepts to create xml from java and SQL. 您可以使用JAXB概念从Java和SQL创建xml。

This link will be helpful for a start. 链接对于开始将很有帮助。

I would recommend using StAX because it's faster than DOM and you know exactly what is going to the XML. 我建议使用StAX,因为它比DOM快,并且您确切知道XML的含义。

Here is the link to a tutorial. 这是教程的链接

What is your main purpose? 您的主要目的是什么? If you're trying to learn JDBC or XML APIs, or this is your application biz logic, the answers provided by Rion are good for start. 如果您想学习JDBC或XML API,或者这是您的应用业务逻辑,那么Rion提供的答案非常适合入门。

But if you're trying just to fetch some data from DB and convert them to XML, I think Data Benerator framework is good for you. 但是,如果您只是尝试从数据库中获取一些数据并将其转换为XML,我认为Data Benerator框架对您很有用。 It has been designed for database and load testing, but could be useful for you too. 它是为数据库和负载测试而设计的,但对您也可能有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM