package metu.java.mysql;
/**
*
* @author Okie Eko Wardoyo
*/
import java.sql.*;
public class MetuJavaMySql {
public static void main(String[] args) {
try{
//tahap pertama register driver class
Class.forName("com.mysql.jdbc.Driver");
//tahab kedua creating connection
Connection con=DriverManager.getConnection(
"jdbc:mysql://localhost:3306/metudb","root","");
//tahab ketiga creating statement
Statement stmt=con.createStatement();
//tahab keempat Executing queries
ResultSet rs=stmt.executeQuery("select * from table_metu");
while(rs.next())
System.out.println(rs.getString(1));
//tahab kelima close connection
con.close();
}catch(Exception e){
System.out.println(e);
}
}
}