Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

public class Main {
    public static void main(String[] argv) throws Exception {
        String driverName = "org.gjt.mm.mysql.Driver";
        Class.forName(driverName);

        String serverName = "localhost";
        String mydatabase = "mydatabase";
        String url = "jdbc:mysql://" + serverName + "/" + mydatabase;
        String username = "username";
        String password = "password";
        Connection connection = DriverManager.getConnection(url, username, password);

        Statement stmt = connection.createStatement();

        String filename = "c:/outfile.txt";
        String tablename = "mysql_2_table";
        stmt.executeUpdate("SELECT * INTO OUTFILE \"" + filename + "\" FROM " + tablename);

    }
}