cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rick Shaw (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CASSANDRA-2732) StringIndexOutOfBoundsException when specifying JDBC connection string without user and password
Date Mon, 06 Jun 2011 21:04:59 GMT

    [ https://issues.apache.org/jira/browse/CASSANDRA-2732?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13045104#comment-13045104
] 

Rick Shaw commented on CASSANDRA-2732:
--------------------------------------

I looked at this area quite extensively in updating the semantics for the JDBC C* suite.

The issue is that the current implementation is very strict in its requested format. It accepts
no variations, including requiring the username and password in the URI. But none of the auth/auth
stuff was even hooked up to the Thrift connection so it was really not going anywhere anyway.
Not to mention that the URI is really not a very wise place to put a password anyway. 

In a revised implementation I have used the URI parser in the java.util library. It offers
a wealth of error checking and defaulting to happen (with judicious enhancements).

This proposed implementation can handle any supportable URI variation after the required "java:cassandra".
The implementation defaults to "localhost" as a site and "9160" as a port so it can be as
simple as : "jdbc:cassandra:/Test".

Using the URI library did cause one small incompatibility: The credentials of UN and PW need
to NOT use a slash "/" to separate them. It confuses it with other parts of a standard URI
(in this case the start of the "path"). I chose the semicolon ";" for now but colon (":" works
as well and seems like it fits in as well... I'd gladly listen to other approaches??

So a more robust example URI would be "jdbc:cassandra://user;secret@my.host.com:9170/Standard".

I also hooked up the Properties argument in the constructor so you can use the Properties
argument or the user and password arguments in {{DriverMananger}} or {{DriverManagerConnectionFactory}}
or similar classes. Note that now if you include the UN/PW anywhere it will attempt to use
it. So you need to mean it...

I will be cutting a new JIRA ticket for the comprehensive patch. I will point this ticket
to it when it hits.

But discussion on this point is very welcome.




> StringIndexOutOfBoundsException when specifying JDBC connection string without user and
password
> ------------------------------------------------------------------------------------------------
>
>                 Key: CASSANDRA-2732
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-2732
>             Project: Cassandra
>          Issue Type: Bug
>    Affects Versions: 0.8 beta 1
>            Reporter: Cathy Daw
>            Assignee: Rick Shaw
>            Priority: Trivial
>              Labels: cql
>
> *PASS: specify connection string user and password*
> _connection = DriverManager.getConnection("jdbc:cassandra:root/root@localhost:9170/default")_
> *FAIL: specify connection string without user and password*
> _connection = DriverManager.getConnection("jdbc:cassandra://localhost:9170/default")_
> {code}
> [junit] String index out of range: -1
> [junit] java.lang.StringIndexOutOfBoundsException: String index out of range: -1
> [junit] at java.lang.String.substring(String.java:1937)
> [junit] at org.apache.cassandra.cql.jdbc.CassandraConnection.<init>(CassandraConnection.java:74)
> [junit] at org.apache.cassandra.cql.jdbc.CassandraConnection.<init>(CassandraConnection.java:74)
> [junit] at org.apache.cassandra.cql.jdbc.CassandraDriver.connect(CassandraDriver.java:86)
> [junit] at java.sql.DriverManager.getConnection(DriverManager.java:582)
> [junit] at java.sql.DriverManager.getConnection(DriverManager.java:207)
> [junit] at com.datastax.cql.runJDBCSmokeTest.setUpBeforeClass(runJDBCSmokeTest.java:45)
> {code}

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

Mime
View raw message