Java DB:修订间差异

来自牛奶河Wiki
跳到导航 跳到搜索
(创建页面,内容为“===MySQL ==== // sDrive = "com.mysql.jdbc.Driver"; // MySQL 8.0 以上版本 - JDBC 驱动名及数据库 URL sDrive = "com.mysql.cj.jdbc.Driver"; sJdbc = "jdbc:mysql://%s:%s/%s?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC"; String sHost, sPort, sDB, sUser, sPasswd; sHost = dbinfo.get("host"); sPort = dbinfo.get("port"); sDB = dbinfo.get("db"); sUser = dbinfo.get("user"); sPasswd = dbinfo.get("passwd"); // register JDBC Driver Clas…”)
 
 
(未显示同一用户的1个中间版本)
第1行: 第1行:
===MySQL ====
=== Public ===
// sDrive = "com.mysql.jdbc.Driver";
// MySQL 8.0 以上版本 - JDBC 驱动名及数据库 URL
sDrive = "com.mysql.cj.jdbc.Driver";
sJdbc = "jdbc:mysql://%s:%s/%s?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC";
String sHost, sPort, sDB, sUser, sPasswd;
sHost = dbinfo.get("host");
sPort = dbinfo.get("port");
sDB = dbinfo.get("db");
sUser = dbinfo.get("user");
sPasswd = dbinfo.get("passwd");
  // register JDBC Driver
  // register JDBC Driver
  Class.forName(sDrive);
  Class.forName(sDrive);
第44行: 第33行:
  // execute sql and not return, ddl/insert/delete/...
  // execute sql and not return, ddl/insert/delete/...
  curr.execute(sSQL);
  curr.execute(sSQL);
=== MySQL ===
// sDrive = "com.mysql.jdbc.Driver";
// MySQL 8.0 以上版本 - JDBC 驱动名及数据库 URL
sDrive = "com.mysql.cj.jdbc.Driver";
sJdbc = "jdbc:mysql://%s:%s/%s?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC";
String sHost, sPort, sDB, sUser, sPasswd;
sHost = dbinfo.get("host");
sPort = dbinfo.get("port");
sDB = dbinfo.get("db");
sUser = dbinfo.get("user");
sPasswd = dbinfo.get("passwd");


[[分类:Develop]]
[[分类:Develop]]
[[分类:Java]]
[[分类:Java]]

2024年2月26日 (一) 10:05的最新版本

Public

// register JDBC Driver
Class.forName(sDrive);
conn = DriverManager.getConnection(sJdbc, sUser, sPasswd);
curr = conn.createStatement();
// execute sql and return result set
rs = curr.executeQuery(sSQL);

rs.getMetaData().getColumnCount();
rs.getMetaData().getColumnName(j)
obj1 = rs.getObject(j);
lcol1.add(obj1 == null?null:obj1.toString());  // ArrayList<String> lcol1 = new ArrayList<>();
rs getMetaData getColumnCount 结果集列数量
getColumnName 列名称
getColumnType 列数据类型
getObject 列值
// execute sql and not return, ddl/insert/delete/...
curr.execute(sSQL);

MySQL

// sDrive = "com.mysql.jdbc.Driver";
// MySQL 8.0 以上版本 - JDBC 驱动名及数据库 URL
sDrive = "com.mysql.cj.jdbc.Driver";
sJdbc = "jdbc:mysql://%s:%s/%s?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC";
String sHost, sPort, sDB, sUser, sPasswd;
sHost = dbinfo.get("host");
sPort = dbinfo.get("port");
sDB = dbinfo.get("db");
sUser = dbinfo.get("user");
sPasswd = dbinfo.get("passwd");