Java SQL Execute executeCall(Connection connection, String command, String schemaName, String tableName, int paramLength)

Here you can find the source of executeCall(Connection connection, String command, String schemaName, String tableName, int paramLength)

Description

Executes the given call (does not commit)

License

Open Source License

Parameter

Parameter Description
connection Database connection
command Command to execute
schemaName Name of selected schema
tableName Name of selected table
paramLength Length of short params needed for the command

Exception

Parameter Description
SQLException an exception

Declaration

private static void executeCall(Connection connection, String command,
        String schemaName, String tableName, int paramLength)
        throws SQLException 

Method Source Code

//package com.java2s;
/*/*from w  w w.  j  a v a  2  s .c o m*/
 * Artifactory is a binaries repository manager.
 * Copyright (C) 2012 JFrog Ltd.
 *
 * Artifactory is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Artifactory is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with Artifactory.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.sql.CallableStatement;
import java.sql.Connection;

import java.sql.SQLException;

public class Main {
    /**
     * Executes the given call (does not commit)
     *
     * @param connection  Database connection
     * @param command     Command to execute
     * @param schemaName  Name of selected schema
     * @param tableName   Name of selected table
     * @param paramLength Length of short params needed for the command
     * @throws SQLException
     */
    private static void executeCall(Connection connection, String command,
            String schemaName, String tableName, int paramLength)
            throws SQLException {
        CallableStatement cs = connection.prepareCall(command);
        cs.setString(1, schemaName);
        cs.setString(2, tableName);
        paramLength += 3;
        for (int i = 3; i < paramLength; i++) {
            cs.setShort(i, (short) 1);
        }
        cs.execute();
    }
}

Related

  1. execute(Connection connection, String sql, boolean closeConn)
  2. execute(final String url, final String username, final String password, final String sql, final Consumer consumer)
  3. execute(List sql)
  4. execute(Statement statement, String sql)
  5. execute(String sql, Connection connection)
  6. executeCallable(Connection conn, String sql)
  7. executeCreateDB(String className, String URL, String userName, String password, String dbName)
  8. executeDDL(final Connection connection, final String sql, final int... ignoreErrors)
  9. executeDDL(String ddl)