
org.tranql.connector.sqlserver2000.XAMCF Maven / Gradle / Ivy
The newest version!
/*
* Copyright (c) 2005 - 2007, Tranql project contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.tranql.connector.sqlserver2000;
import com.microsoft.jdbcx.sqlserver.SQLServerDataSource;
import org.tranql.connector.NoExceptionsAreFatalSorter;
import org.tranql.connector.jdbc.AbstractXADataSourceMCF;
/**
* ManagedConnectionFactory that wraps a SQLServerDataSource.
*
* @version $Revision: 878 $ $Date: 2013-04-05 12:20:17 -0700 (Fri, 05 Apr 2013) $
*/
public class XAMCF extends AbstractXADataSourceMCF {
private String password = "";
/**
* Default constructor for a SQLServerDataSource wrapper.
*/
public XAMCF() {
super(new SQLServerDataSource(), new NoExceptionsAreFatalSorter());
}
public void setDatabaseName(String dbname) {
xaDataSource.setDatabaseName(dbname);
}
public String getDatabaseName() {
return xaDataSource.getDatabaseName();
}
public void setPassword(String pwd) {
this.password = pwd;
xaDataSource.setPassword(pwd);
}
public String getPassword() {
return password;
}
public void setPortNumber(Integer pn) {
xaDataSource.setPortNumber(pn == null ? 0 : pn);
}
public Integer getPortNumber() {
return xaDataSource.getPortNumber();
}
public void setServerName(String sn) {
xaDataSource.setServerName(sn);
}
public String getServerName() {
return xaDataSource.getServerName();
}
public void setUserName(String user) {
xaDataSource.setUser(user);
}
public String getUserName() {
return xaDataSource.getUser();
}
public void setSelectMethod(String method) {
xaDataSource.setSelectMethod(method);
}
public String getSelectMethod() {
return xaDataSource.getSelectMethod();
}
public void setSendStringParameters(Boolean value) {
xaDataSource.setSendStringParametersAsUnicode(value);
}
public Boolean getSendStringParameters() {
return xaDataSource.getSendStringParametersAsUnicode();
}
/**
* Equality is defined in terms of the serverName, portNumber and databaseName properties
*/
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj instanceof XAMCF) {
SQLServerDataSource other = ((XAMCF) obj).xaDataSource;
return equals(xaDataSource.getServerName(), other.getServerName()) &&
xaDataSource.getPortNumber() == other.getPortNumber() &&
equals(xaDataSource.getDatabaseName(), other.getDatabaseName());
} else {
return false;
}
}
private static boolean equals(String a, String b) {
return a == b || a != null && a.equals(b);
}
public int hashCode() {
return hashCode(xaDataSource.getServerName()) ^ xaDataSource.getPortNumber() ^ hashCode(xaDataSource.getDatabaseName());
}
private static int hashCode(String s) {
return s == null ? 0 : s.hashCode();
}
public String toString() {
return "XAMCF[" + getDatabaseName() + ']';
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy