Java tutorial
import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; public class Main { private static final String DRIVER = "com.mysql.jdbc.Driver"; private static final String HOST = "192.168.56.101"; private static final String PORT = "3316"; private static final String CONNECTION_URL = "jdbc:mysql://" + HOST + ":" + PORT + "/"; private static final String USERNAME = "user"; private static final String PASSWORD = "pwd"; private static final String DATABASE = "db"; private static final String TABLE = "table"; private static final String QUERY = "select * from " + DATABASE + "." + TABLE + " where 1=0"; public static void main(String[] args) throws ClassNotFoundException, SQLException { Class.forName(DRIVER); Connection con = DriverManager.getConnection(CONNECTION_URL, USERNAME, PASSWORD); ResultSet rs = con.createStatement().executeQuery(QUERY); if (rs != null) { System.out.println("Column Type\t\t Column Name"); ResultSetMetaData rsmd = rs.getMetaData(); for (int i = 1; i <= rsmd.getColumnCount(); i++) { System.out.println(rsmd.getColumnTypeName(i) + "\t\t\t" + rsmd.getColumnName(i)); } } } }