Here you can find the source of update_Db(DataSource ds, String query)
static public int update_Db(DataSource ds, String query) throws SQLException
//package com.java2s; /*/*from w w w. j av a 2s. c om*/ * Copyright (c) 2014-2015 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html * */ import java.sql.Connection; import java.sql.SQLException; import java.sql.Statement; import javax.sql.DataSource; public class Main { static public int update_Db(DataSource ds, String query) throws SQLException { // // Run the query // Connection conn = null; Statement stmt = null; int updated = 0; try { conn = ds.getConnection(); stmt = conn.createStatement(); updated = stmt.executeUpdate(query); } catch (SQLException e) { throw e; } finally { try { if (stmt != null) stmt.close(); if (conn != null) conn.close(); } catch (SQLException e) { e.printStackTrace(); } } return updated; } }