[ 
https://issues.apache.org/jira/browse/CASSANDRA-2842?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Rick Shaw updated CASSANDRA-2842:
---------------------------------

    Attachment: pass-if-not-right-driver-v1.txt

This test has been run against v1.0.3 of the driver. In that version the 
{{connect(...)}} method of {{CassandraDriver}} is called with an unsupported 
protocol:subprotocol in its URL. It recognizes it is not the proper protocol 
but erroneously throws an exception rather than returning a null to the caller 
stating that it can not handle it, so please move on. The patch is based on the 
current trunk of {{/drivers}} (v1.0.4).

> Hive JDBC connections fail with InvalidUrlException when both the C* and Hive 
> JDBC drivers are loaded
> -----------------------------------------------------------------------------------------------------
>
>                 Key: CASSANDRA-2842
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-2842
>             Project: Cassandra
>          Issue Type: Bug
>            Reporter: Cathy Daw
>            Priority: Trivial
>         Attachments: pass-if-not-right-driver-v1.txt
>
>
> Hive connections fail with InvalidUrlException when both the C* and Hive JDBC 
> drivers are loaded, and it seems the URL is being interpreted as a C* url.
> {code}
>       Caused an ERROR
>     [junit] Invalid connection url:jdbc:hive://127.0.0.1:10000/default. 
> should start with jdbc:cassandra
>     [junit] org.apache.cassandra.cql.jdbc.InvalidUrlException: Invalid 
> connection url:jdbc:hive://127.0.0.1:10000/default. should start with 
> jdbc:cassandra
>     [junit]   at 
> org.apache.cassandra.cql.jdbc.CassandraDriver.connect(CassandraDriver.java:90)
>     [junit]   at java.sql.DriverManager.getConnection(DriverManager.java:582)
>     [junit]   at java.sql.DriverManager.getConnection(DriverManager.java:185)
>     [junit]   at 
> com.datastax.bugRepros.repro_connection_error.test1_runHiveBeforeJdbc(repro_connection_error.java:34)
> {code}
> *Code Snippet: intended to illustrate the connection issues* 
> * Copy file to test directory
> * Change package declaration
> * run:  ant test -Dtest.name=repro_conn_error
> {code}
> package com.datastax.bugRepros;
> import java.sql.DriverManager;
> import java.sql.Connection;
> import java.sql.SQLException;
> import java.util.Enumeration;
> import org.junit.Test;
> public class repro_conn_error
> {
>     @Test
>     public void jdbcConnectionError() throws Exception 
>     {  
>         // Create Hive JDBC Connection - will succeed if      
>         try 
>         {
>             // Uncomment loading C* driver to reproduce bug
>             Class.forName("org.apache.cassandra.cql.jdbc.CassandraDriver");
>             
>             // Load Hive driver and connect
>             Class.forName("org.apache.hadoop.hive.jdbc.HiveDriver");
>             Connection hiveConn = 
> DriverManager.getConnection("jdbc:hive://127.0.0.1:10000/default", "", "");
>             hiveConn.close();  
>             System.out.println("successful hive connection");
>         } catch (SQLException e) {
>             System.out.println("unsuccessful hive connection");
>             e.printStackTrace();
>         }
>         
>         // Create C* JDBC Connection
>         try 
>         {
>             Class.forName("org.apache.cassandra.cql.jdbc.CassandraDriver");
>             Connection jdbcConn = 
> DriverManager.getConnection("jdbc:cassandra:root/[email protected]:9160/default");
>      
>             jdbcConn.close();    
>             System.out.println("successful c* connection");
>         } catch (SQLException e) {
>             System.out.println("unsuccessful c* connection");
>             e.printStackTrace();
>         }
>         
>         // Print out all loaded JDBC drivers.
>         Enumeration d = java.sql.DriverManager.getDrivers();
>         
>         while (d.hasMoreElements()) {
>             Object driverAsObject = d.nextElement();
>             System.out.println("JDBC driver=" + driverAsObject);
>         }
>     }
> }
> {code}

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to