JDBC 管理層,靜態方法,無需實例化。載入驅動:
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:student";
Connection conn = DriverManager.getConnection(url, "anonymous", "");
URL 格式:jdbc:子協議:子名稱。成功返回 Connection 物件,失敗拋異常。
createStatement():建立 Statement 發送查詢。close():關閉連線釋放資源。isClosed():判斷連線狀態。後續操作皆基於 Connection 物件。