Connection connection = DriverManager.getConnection(url, username, password); Statement statement = connection.createStatement(); ResultSet resultSet = statement.executeQuery("SELECT * FROM transactions"); resultSet.close(); statement.close(); connection.close(); Connection connection = DriverManager.getConnection(url, username, password); Statement statement = connection.createStatement(); statement.addBatch("INSERT INTO transactions (tx_hash, amount) VALUES ('hash1', 100)"); statement.addBatch("INSERT INTO transactions (tx_hash, amount) VALUES ('hash2', 200)"); statement.addBatch("INSERT INTO transactions (tx_hash, amount) VALUES ('hash3', 300)"); statement.executeBatch(); statement.close(); connection.close(); Connection connection = DriverManager.getConnection(url, username, password); PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM transactions WHERE tx_hash = ?"); preparedStatement.setString(1, "hash123"); ResultSet resultSet = preparedStatement.executeQuery(); resultSet.close(); preparedStatement.close(); connection.close(); HikariConfig config = new HikariConfig(); config.setJdbcUrl(url); config.setUsername(username); config.setPassword(password); HikariDataSource dataSource = new HikariDataSource(config); Connection connection = dataSource.getConnection(); connection.close(); dataSource.close();


上一篇:
下一篇:
切换中文