Java examples for JDBC:MySQL
Exporting a MySQL Table to a Flat File
import java.sql.Connection; import java.sql.SQLException; import java.sql.Statement; public class Main { public void main(String[] argv) { Connection connection = null; try {// w w w .ja v a2 s .c o m // Create the statement Statement stmt = connection.createStatement(); // Export the data String filename = "c:\\\\temp\\\\outfile.txt"; String tablename = "mytable"; stmt.executeUpdate("SELECT * INTO OUTFILE \"" + filename + "\" FROM " + tablename); } catch (SQLException e) { } } }