111
private int M1() { int res = -1; try { Connection conn = getConnection(); String sql = "UPDATE `user` set money=666 where id=?"; Object[] objs = new Object[]{"1"}; res = JdbcUtils.executeUpdate(conn, sql, objs); System.out.println(res); } catch (Exception e) { e.printStackTrace(); } return res; } private Connection getConnection() throws SQLException { BasicDataSource bs = new BasicDataSource(); bs.setDriverClassName("com.mysql.jdbc.Driver"); bs.setUrl("jdbc:mysql://localhost:3306/jdbc"); bs.setUsername("root"); bs.setPassword("xxxxxx"); bs.setInitialSize(20); Connection connection = bs.getConnection(); return connection; }
原文地址:https://www.cnblogs.com/kikyoqiang/p/11780595.html
时间: 2024-10-15 14:31:10