(同じ利用者による、間の4版が非表示) | |||
7行目: | 7行目: | ||
==例== | ==例== | ||
public static ArrayList<Item> | static final String URL = "jdbc:mysql://localhost:3306/day_results"; | ||
try (Connection | static final String USER = "yoosuke"; | ||
Statement stm = | static final String PASSWD = "hoge"; | ||
public static ArrayList<Item> getRow() { | |||
try (Connection cnc = DriverManager.getConnection(URL, USER, PASSWD);) { | |||
Statement stm = cnc.createStatement(); | |||
... | |||
2019年6月28日 (金) 20:06時点における最新版
私は一連のJDBC(Java DataBase Connectivity)ドライバを管理します。
メソッド
- getConnection - 指定データベースURLへの接続を試みる
例
static final String URL = "jdbc:mysql://localhost:3306/day_results"; static final String USER = "yoosuke"; static final String PASSWD = "hoge"; public static ArrayList<Item> getRow() { try (Connection cnc = DriverManager.getConnection(URL, USER, PASSWD);) { Statement stm = cnc.createStatement(); ...