Java SQL Query runQuery(Connection con, String query)

Here you can find the source of runQuery(Connection con, String query)

Description

to run an update query such as update, delete

License

Apache License

Parameter

Parameter Description
query custom query

Exception

Parameter Description
SQLException throws an exception if an error occurs

Declaration

public static int runQuery(Connection con, String query) throws SQLException 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.sql.Connection;

import java.sql.PreparedStatement;

import java.sql.SQLException;

public class Main {
    /**/*from ww w  . j  a  va2s  .com*/
     * to run an update query such as update, delete
     * 
     * @param query
     *            custom query
     * @throws SQLException
     *             throws an exception if an error occurs
     */
    public static int runQuery(Connection con, String query) throws SQLException {
        PreparedStatement st = con.prepareStatement(query);
        return st.executeUpdate();
    }
}

Related

  1. query(Connection connection, String sql, boolean isClose, Object... params)
  2. queryForList(Connection conn, String sql, int limit)
  3. queryObjectList(Connection con, String sql, Class objClass)
  4. queryProjectTicketIdFromTicketId(Connection db, int ticketId)
  5. queryReturnRS(String sql)
  6. runSqlSelect(String sqlQuery, Connection databaseConnection)