com.github.adejanovski.cassandra.jdbc.CassandraDriver Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cassandra-jdbc-wrapper Show documentation
Show all versions of cassandra-jdbc-wrapper Show documentation
JDBC wrapper for the DataStax CQL Java Driver.
/*
*
* 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 com.github.adejanovski.cassandra.jdbc;
import static com.github.adejanovski.cassandra.jdbc.Utils.NOT_SUPPORTED;
import static com.github.adejanovski.cassandra.jdbc.Utils.PROTOCOL;
import static com.github.adejanovski.cassandra.jdbc.Utils.TAG_PASSWORD;
import static com.github.adejanovski.cassandra.jdbc.Utils.TAG_USER;
import java.sql.*;
import java.util.Enumeration;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.ExecutionException;
import com.google.common.cache.*;
import com.google.common.collect.ImmutableMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The Class CassandraDriver.
*/
public class CassandraDriver implements Driver
{
public static final int DVR_MAJOR_VERSION = 2;
public static final int DVR_MINOR_VERSION = 1;
public static final int DVR_PATCH_VERSION = 6;
public static final String DVR_NAME = "Datastax JDBC Driver";
private static final Logger logger = LoggerFactory.getLogger(CassandraDriver.class);
static
{
// Register the CassandraDriver with DriverManager
try
{
CassandraDriver driverInst = new CassandraDriver();
DriverManager.registerDriver(driverInst);
}
catch (SQLException e)
{
throw new RuntimeException(e.getMessage());
}
}
// Caches Sessions so that multiple CassandraConnections created with the same parameters use the same Session.
private final LoadingCache