
org.firebirdsql.gds.ng.jna.JnaDatabaseConnection Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jaybird-native Show documentation
Show all versions of jaybird-native Show documentation
Native GDS Factory Plugin for Jaybird JDBC Driver
The newest version!
/*
* Firebird Open Source JDBC Driver
*
* Distributable under LGPL license.
* You may obtain a copy of the License at http://www.gnu.org/copyleft/lgpl.html
*
* This program 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
* LGPL License for more details.
*
* This file was created by members of the firebird development team.
* All individual contributions remain the Copyright (C) of those
* individuals. Contributors to this file are either listed here or
* can be obtained from a source control history command.
*
* All rights reserved.
*/
package org.firebirdsql.gds.ng.jna;
import org.firebirdsql.encodings.EncodingFactory;
import org.firebirdsql.encodings.IEncodingFactory;
import org.firebirdsql.gds.JaybirdErrorCodes;
import org.firebirdsql.gds.impl.DbAttachInfo;
import org.firebirdsql.gds.ng.FbExceptionBuilder;
import org.firebirdsql.gds.ng.IConnectionProperties;
import org.firebirdsql.jna.fbclient.FbClientLibrary;
import java.sql.SQLException;
/**
* Class handling the initial setup of the JNA database connection.
*
* @author Mark Rotteveel
* @since 3.0
*/
public class JnaDatabaseConnection extends JnaConnection {
/**
* Creates a JnaDatabaseConnection (without establishing a connection to the server).
*
* @param clientLibrary
* Client library to use
* @param connectionProperties
* Connection properties
*/
public JnaDatabaseConnection(FbClientLibrary clientLibrary, IConnectionProperties connectionProperties)
throws SQLException {
this(clientLibrary, connectionProperties, EncodingFactory.getPlatformDefault());
}
/**
* Creates a JnaDatabaseConnection (without establishing a connection to the server).
*
* @param clientLibrary
* Client library to use
* @param connectionProperties
* Connection properties
* @param encodingFactory
* Factory for encoding definitions
*/
public JnaDatabaseConnection(FbClientLibrary clientLibrary, IConnectionProperties connectionProperties,
IEncodingFactory encodingFactory) throws SQLException {
super(clientLibrary, connectionProperties, encodingFactory);
}
@Override
protected String createAttachUrl(DbAttachInfo dbAttachInfo, IConnectionProperties connectionProperties)
throws SQLException {
if (!dbAttachInfo.hasAttachObjectName()) {
throw FbExceptionBuilder.forNonTransientConnectionException(JaybirdErrorCodes.jb_invalidConnectionString)
// Using original attach object name as that may well be non-null even if it is null in dbAttachInfo
.messageParameter(connectionProperties.getAttachObjectName(),
"null or empty database name in connection string")
.toSQLException();
}
return toAttachUrl(dbAttachInfo);
}
/**
* Contrary to the description in the super class, this will simply return an unconnected instance.
*
* @return FbDatabase instance
*/
@Override
public JnaDatabase identify() throws SQLException {
return new JnaDatabase(this);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy