当前位置:首页 >新闻中心 >数据库中间件 MyCAT源码分析 —— PreparedStatement 重新入门 正文

数据库中间件 MyCAT源码分析 —— PreparedStatement 重新入门

来源:益强资讯优选   作者:数据库   时间:2025-11-05 03:29:59
数据库中间件 MyCAT源码分析 —— PreparedStatement 重新入门
复制public class PreparedStatementDemo {      publicstatic void main(String[] args) throws ClassNotFoundException,数据 SQLException {          // 1. 获得数据库连接          Class.forName("com.mysql.jdbc.Driver");          Connection conn = DriverManager.getConnection("jdbc:mysql://127.0.0.1:8066/dbtest?useServerPrepStmts=true", "root", "123456");          // PreparedStatement          PreparedStatement ps = conn.prepareStatement("SELECT id, username, password FROM t_user WHERE id = ?");          ps.setLong(1, Math.abs(new Random().nextLong()));          // execute         ps.executeQuery();      }  }   1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.

标签:

责任编辑:数据库