Connect to MySQL in Java

mysql

An Example of connecting to MySQL using JDBC Driver.

A typical example code of connect to database will look like this

read more

Download JDBC Driver

A JDBC driver is a software component enabling a Java application to interact with a database[1]
You can either download the JDBC driver from the database vendor/provider website (But usually they come with the database installation.)
Below are the list of database vendor and their website url.

read more

Write Dom to Xml File (LSSerializer)

 

Example Output : justexample.xml

Reference
http://docs.oracle.com/javase/1.5.0/docs/api/org/w3c/dom/ls/class-use/LSOutput.html
http://docs.oracle.com/javase/1.5.0/docs/api/org/w3c/dom/bootstrap/DOMImplementationRegistry.html
http://docs.oracle.com/javase/1.5.0/docs/api/org/w3c/dom/ls/DOMImplementationLS.html

read more

Read a XML file (LS-DOM)

Sample file : justexample.xml

Example Output

Reference
http://docs.oracle.com/javase/1.5.0/docs/api/org/w3c/dom/ls/DOMImplementationLS.html

read more

Write Dom to Xml File (Transformer)

This example show you how to construct a Java Document Object Model (DOM) using DOM API and then write the DOM object into XML file.
 

Example Output : justexample.xml

Reference
http://docs.oracle.com/javase/1.5.0/docs/api/javax/xml/transform/Transformer.html#transform(javax.xml.transform.Source, javax.xml.transform.Result)

read more

Read a XML File (SAX)

Sample file : justexample.xml

 

read more

Read a XML File (DOM)

Sample file : justexample.xml

 

Example Output

Reference
http://docs.oracle.com/javase/1.5.0/docs/api/org/w3c/dom/Document.html
http://docs.oracle.com/javase/1.5.0/docs/api/javax/xml/parsers/DocumentBuilderFactory.html

read more

Variable-Length Argument Lists in java

 

Reference

http://today.java.net/pub/a/today/2004/04/19/varargs.html

read more

Write file with PrintWriter

 


Reference
http://docs.oracle.com/javase/1.5.0/docs/api/java/io/PrintWriter.html
http://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html

read more