프로그래밍/ㆍMySQL
[MySQL] jdbc 연동 테스트 - 이클립스와 MySQL 연결 확인하기
쪼재
2012. 2. 24. 20:41
아래 손가락을 눌러주세요.
DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "admin");
-> ("mysql의 3306포트 데이터베이스 test에 연결", "mysql계정 아이디", "mysql계정 비밀번호")
import java.sql.*; // jdbc 연동 테스트 public class DriverTest { public static void main(String args[]) { Connection conn; try { Class.forName("com.mysql.jdbc.Driver").newInstance(); conn = DriverManager.getConnection( "jdbc:mysql://localhost:3306/test", "root", "admin"); System.out.println("Success!"); } catch (SQLException ex) { System.out.println("SQLException:" + ex); } catch (Exception e) { System.out.println("Exception:" + e); } } }