import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.*;
import com.mysql.jdbc.Connection;


public class test {

 static test msg = new test();
 public static void main(String[] args) throws ClassNotFoundException, SQLException {
  msg .go();
 }
 public void go() throws ClassNotFoundException, SQLException{
  Class.forName("org.gjt.mm.mysql.Driver");
  System.out.println("드라이버가  정상 설치 되었습니다.");
 
  Connection conn = null;
  String url ="jdbc:mysql://localhost:3306/java";
  String id = "root";
  String pass = "12345678";
  Statement stmt = null;
  ResultSet rs = null;
  String query = "select * from koleekr";
 
  conn =  (Connection) DriverManager.getConnection(url, id, pass);
  stmt = conn.createStatement();
  rs = stmt.executeQuery(query);
 
 
  while(rs.next()){
   System.out.println(rs.getInt(1)+":"+rs.getString(2) );  
  }
  rs.close();
  stmt.close();
  conn.close();
 }//go()종료

}//클래스 종료 

+ Recent posts