db-ddlutils-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Einsle <rob...@einsle.de>
Subject Re: Closing Database while retriving the Platform
Date Fri, 28 Oct 2005 13:05:12 GMT
Hy

here is the matching Code-Sniplet from PlatformUtils:

--- cut ---
    /**
     * Tries to determine the database type for the given data source. 
Note that this will establish
     * a connection to the database.
     *
     * @param dataSource The data source
     * @return The database type or <code>null</code> if the database 
type couldn't be determined
     */
    public String determineDatabaseType(DataSource dataSource) throws 
DynaSqlException
    {
        Connection connection = null;

        try
        {
            connection = dataSource.getConnection();
           
            DatabaseMetaData metaData = connection.getMetaData();

            return determineDatabaseType(metaData.getDriverName(), 
metaData.getURL());
        }
        catch (SQLException ex)
        {
            throw new DynaSqlException("Error while reading the database 
metadata", ex);
        }
        finally
        {
            if (connection != null)
            {
                try
                {
                    connection.close();
                }
                catch (SQLException ex)
                {
                    // we ignore this one
                }
            }
        }
    }
--- cut ---

Robert Einsle schrieb:

> Hy,
>
> an aditional Question. When i retrive the Platform (Platform platform 
> = PlatformFactory.createNewPlatformInstance(<Datasource));) DdlUtils 
> closes the java.sql.Connection inside the Datasource. Is it possible 
> to let DdlUtils not close the Conenction?
>
> So i have to create an Connection, let create the Platform, the create 
> the Connection again.
>
> Thanks for Help.
>
> \Robert
>
\Robert

Mime
View raw message