JDBC數據庫編程基本流程

一、加載驅動類數據庫

Class.forName(「」);url

 

二、建立數據庫鏈接對象

Connection con = DriverManager.getConnection(url, user, password);get

 

三、建立Statement對象io

Statement stat = con.createStatement();date

 

四、數據庫操做數據

stat.executeUpdate(「SQL更新語句」);查詢

ResultSet rs = stat.execulteQuery(「SQL查詢語句」);word

 

五、關閉數據庫鏈接co

rs.close();

stat.close();

con.close();

相關文章
相關標籤/搜索