Java DataSource getConnectionFromDataSource(DataSource ds)

Here you can find the source of getConnectionFromDataSource(DataSource ds)

Description

Creates a connection to the database from a Data Source

License

Open Source License

Parameter

Parameter Description
ds Data source containing parameters needed to connect to the database

Exception

Parameter Description
SQLException an exception

Return

A connection to the database

Declaration

public static Connection getConnectionFromDataSource(DataSource ds) throws SQLException 

Method Source Code


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

import java.sql.Connection;
import java.sql.SQLException;
import javax.sql.DataSource;

public class Main {
    /**//w  ww .  j a v a 2s.  com
     * Creates a connection to the database from a Data Source 
     * 
     * @param ds Data source containing parameters needed to connect to the database
     * @return A connection to the database
     * @throws SQLException
     */
    public static Connection getConnectionFromDataSource(DataSource ds) throws SQLException {
        Connection conn = ds.getConnection();
        conn.setAutoCommit(false);

        return conn;
    }
}

Related

  1. execute(String execute, DataSource datasource)
  2. executeQuery(DataSource dataSource, String... queries)
  3. getConnection(CommonDataSource dataSource)
  4. getConnection(DataSource dataSource)
  5. getConnection(final DataSource ds, final boolean autoCommit)
  6. getDatabaseName(DataSource dataSource)
  7. getDataSource(String jndi)
  8. getDataSource(String jndiName)
  9. getDataSource(String service)