?? connectionaccess.java
字號:
package model.connection;
import java.sql.*;
/**
* 用作連接Access數據庫
* @author Cynthia
*
*/
public class ConnectionAccess implements Connectable{
//屬性
private Connection conn;
/**
* 構造函數
* @param arg 連接數據庫類型
* @throws ClassNotFoundException 類名沒有找到
* @throws SQLException 連接數據庫時出錯
*/
public ConnectionAccess(String arg) throws ClassNotFoundException,SQLException{
System.out.println("jjca");
String driver = arg;
try{
Class.forName(driver);
String url = "jdbc:odbc:ItemDatabase";
conn = DriverManager.getConnection(url);
}
catch(ClassNotFoundException e){
System.out.println("Class not found!");
}
catch(SQLException e){
System.out.println("Database connection failed!");
}
}
/**接口函數的實現
* @return Connection類型 連接
*/
public Connection connectionDatabase(){return conn;}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -