cassandra-commits mailing list archives

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


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;".

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
> ------------------------------------------------------------------------------------------------
>                 Key: CASSANDRA-2732
>                 URL:
>             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(
> [junit] at org.apache.cassandra.cql.jdbc.CassandraConnection.<init>(
> [junit] at org.apache.cassandra.cql.jdbc.CassandraConnection.<init>(
> [junit] at org.apache.cassandra.cql.jdbc.CassandraDriver.connect(
> [junit] at java.sql.DriverManager.getConnection(
> [junit] at java.sql.DriverManager.getConnection(
> [junit] at com.datastax.cql.runJDBCSmokeTest.setUpBeforeClass(
> {code}

This message is automatically generated by JIRA.
For more information on JIRA, see:

View raw message