Java DataSource assertNotNull(DataSource dataSource)

Here you can find the source of assertNotNull(DataSource dataSource)

Description

Throws IllegalArgumentException if provided datasource is NULL

License

Open Source License

Parameter

Parameter Description
dataSource DataSource instance

Declaration

public static void assertNotNull(DataSource dataSource) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import javax.sql.DataSource;

import java.sql.*;

public class Main {
    /**//from  w  w w.  j a v a2s .c  om
     * Throws {@link IllegalArgumentException} if provided datasource is NULL
     *
     * @param dataSource {@link DataSource} instance
     */
    public static void assertNotNull(DataSource dataSource) {
        if (dataSource == null) {
            throw new IllegalArgumentException("Provided datasource instance is NULL, can't detect database type");
        }
    }

    /**
     * Throws {@link IllegalArgumentException} if provided connection is NULL
     *
     * @param connection {@link Connection} instance
     */
    public static void assertNotNull(Connection connection) {
        if (connection == null) {
            throw new IllegalArgumentException("Provided connection instance is NULL, can't detect database type");
        }
    }
}

Related

  1. batchExecute(DataSource ds, String sql, Object[]... args)
  2. checkTableExists(DataSource dataSource, String tableName)
  3. cleanDB(String ip, DataSource dataSource)
  4. countTable(DataSource dataSource, String tableName)