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.ResultSet;
import java.sql.Statement;
import java.util.Properties;

public class Main {
    public static void main(String[] args) throws Exception {
        Class.forName("com.mysql.jdbc.Driver");
        Connection conn = null;
        Properties info = new Properties();
        // info.put("proxy_type", "4"); // SSL Tunneling
        info.put("proxy_host", "[proxy host]");
        info.put("proxy_port", "[proxy port]");
        info.put("proxy_user", "[proxy user]");
        info.put("proxy_password", "[proxy password]");
        info.put("user", "[db user]");
        info.put("password", "[db pass word]");
        conn = DriverManager.getConnection("jdbc:mysql://[db host]/", info);

        Statement stmt = conn.createStatement();
        ResultSet rs = stmt.executeQuery("Select NOW()");
        rs.next();
        System.out.println("Data- " + rs.getString(1));
        rs.close();
        stmt.close();
        conn.close();
    }
}