Extracting
data from a database through JDBC and creating an XML document from
that data is simple logic. If you have already worked in creating an
XML document using java, then the process getting data from a database
through JDBC and creating an XML document is also easy.
_______________________________________________
_______________________________________________
The
only difference is that you have to map the data that is got from the
database to the XML elements that you are creating.
Creating
an XML document can be done using the classes like DocumentBuilderFactory,
DocumentBuilder, and Document. Using these three you can create a document
object. The next step is to connect to your database through JDBC. This
can be done very easily using a statement like,
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection db = DriverManager.getConnection ("jdbc:oracle:thin:@localhost:1521:mydb",
"userid", "pwd");
Using a
prepared statement and the resultset to get the query executed and getting
the result is very easy and there are lots of examples on that part.
For our issue, you have to create one ResultSetMetaData object. This
object can be loaded with the resultsetmetadata using the getMetaData()
of the resultset object.
Now you
have to loop through the result set and get the column values and store
them in a variable or an array. Then loop through the array and create
text nodes and append them to the root node you have created for the
Document object. You can find an example at http://www.ibm.com/developerworks/edu/x-dw-xextract-i.html.
Dreamtech Press Book Release: Dreamtech Strengthens Its Presence with "Java EE 5 Black Book" (PR.com)
Dreamtech Press, a leading publisher forays into Java EE 5 Education, by introducing new "Java Server Programming Java EE 5 (J2EE 1.5) Black Book"- a book for Java EE 5 education. The book is launched with a combined vision to increase the productivity of Java Professionals by implementing effective learning theories. Book Details: ISBN – 978-81-7722-835-9; Price – 599/- w/CD. [PR.com - July 18, ...
Monitoring network performance with GNetWatch (NewsForge)
GNetWatch is a network monitoring and performance testing tool that lets you can see the status of hosts on your network, send ping requests of varying size and quality of service to hosts, and investigate SNMP information. GNetWatch includes support for using Wireshark and nmap to snoop packets and investigate hosts on the network.
The SocialDNS Project… and Why DNS is Not the Phone Book of the Internet (CircleID)
In this article I will explain the motivations behind the SocialDNS Project. I will justify why the DNS system is NOT the phone book of the Internet. More concretely, DNS is not a public directory nor enables search mechanisms over meta-information related to domains. In this line, I will present the advantages of SocialDNS, a naming and directory system that aims to become the phone book of ...