You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Cathy Daw (JIRA)" <ji...@apache.org> on 2011/07/01 01:03:28 UTC

[jira] [Created] (CASSANDRA-2842) Hive JDBC connections fail with InvalidUrlException when both the C* and Hive JDBC drivers are loaded

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


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/root@127.0.0.1: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

        

[jira] [Commented] (CASSANDRA-2842) Hive JDBC connections fail with InvalidUrlException when both the C* and Hive JDBC drivers are loaded

Posted by "Rick Shaw (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CASSANDRA-2842?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13058658#comment-13058658 ] 

Rick Shaw commented on CASSANDRA-2842:
--------------------------------------

I took a quick look at the Hive sources and I believe you will find the Hive Driver suffers from this defect as well. So if you reversed the order I think it will be the Hive driver that throws an exception rather than deferring to the next driver in the chain of loaded drivers(C*).

> 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
>    Affects Versions: 1.0
>            Reporter: Cathy Daw
>            Assignee: Rick Shaw
>            Priority: Trivial
>             Fix For: 1.0
>
>         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/root@127.0.0.1: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

        

[jira] [Updated] (CASSANDRA-2842) Hive JDBC connections fail with InvalidUrlException when both the C* and Hive JDBC drivers are loaded

Posted by "Rick Shaw (JIRA)" <ji...@apache.org>.
     [ 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/root@127.0.0.1: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