public class DB_JDBC extends Object
demo:
Connection conn = DB_JDBC.getConnection(DB_JDBC.driver_mysql, "jdbc:mysql://localhost:3306/web?user=root&password=root&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull");
ResultSet rs3 = DB_JDBC.executeQuery(conn, "SELECT * FROM web.account;");
System.err.println("xx3 " + DB_JDBC.rs_MapList(rs3));
DB_JDBC.closeConnection(conn);
┌─┐ ┌─┐
┌──┘ ┴───────┘ ┴──┐
│ │
│ ─── │
│ ─┬┘ └┬─ │
│ │
│ ─┴─ │
│ │
└───┐ ┌───┘
│ │
│ │
│ │
│ └──────────────┐
│ │
│ ├─┐
│ author:lelouch ┌─┘
│ │
└─┐ ┐ ┌───────┬──┐ ┌──┘
│ ─┤ ─┤ │ ─┤ ─┤
└──┴──┘ └──┴──┘
神兽保佑
代码无BUG!
| 限定符和类型 | 字段和说明 |
|---|---|
static String |
driver_mysql
mysql驱动
|
| 构造器和说明 |
|---|
DB_JDBC() |
| 限定符和类型 | 方法和说明 |
|---|---|
static void |
closeConnection(Connection conn) |
static Connection |
getConnection(String driver,
String url)
获取一个 Connection对象
|
static Connection |
getConnection(String driver,
String url,
boolean autoCommit)
获取一个 Connection对象
|
static DB_JSelect |
select(Connection con)
查询
|
static DB_JUpdate |
update(Connection con)
更新
|
static String |
valueDispose(Object object) |
public static Connection getConnection(String driver, String url, boolean autoCommit)
driver - db驱动名称url - 连接urlautoCommit - 是否自动提交public static Connection getConnection(String driver, String url)
driver - db驱动名称url - 连接urlpublic static void closeConnection(Connection conn)
public static DB_JSelect select(Connection con)
con - public static DB_JUpdate update(Connection con)
con - Copyright © 2020. All rights reserved.