You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by jb...@apache.org on 2011/06/18 21:19:13 UTC
svn commit: r1137231 [3/3] - in /cassandra/drivers/java: ./
src/org/apache/cassandra/cql/jdbc/
Modified: cassandra/drivers/java/src/org/apache/cassandra/cql/jdbc/CassandraStatement.java
URL: http://svn.apache.org/viewvc/cassandra/drivers/java/src/org/apache/cassandra/cql/jdbc/CassandraStatement.java?rev=1137231&r1=1137230&r2=1137231&view=diff
==============================================================================
--- cassandra/drivers/java/src/org/apache/cassandra/cql/jdbc/CassandraStatement.java (original)
+++ cassandra/drivers/java/src/org/apache/cassandra/cql/jdbc/CassandraStatement.java Sat Jun 18 19:19:13 2011
@@ -20,16 +20,22 @@
*/
package org.apache.cassandra.cql.jdbc;
+import static org.apache.cassandra.cql.jdbc.Utils.*;
+
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
+import java.sql.SQLNonTransientConnectionException;
+import java.sql.SQLRecoverableException;
+import java.sql.SQLSyntaxErrorException;
+import java.sql.SQLTransientConnectionException;
import java.sql.SQLWarning;
import java.sql.Statement;
import java.util.regex.Pattern;
import org.apache.cassandra.thrift.CqlResult;
-import org.apache.cassandra.thrift.CqlResultType;
import org.apache.cassandra.thrift.InvalidRequestException;
import org.apache.cassandra.thrift.SchemaDisagreementException;
import org.apache.cassandra.thrift.TimedOutException;
@@ -40,555 +46,373 @@ import org.apache.thrift.TException;
* Cassandra statement: implementation class for {@link PreparedStatement}.
*/
-class CassandraStatement implements Statement
+class CassandraStatement extends AbstractStatement implements Statement
{
protected static final Pattern UpdatePattern = Pattern.compile("UPDATE .*", Pattern.CASE_INSENSITIVE);
-
+
/** The connection. */
- protected final org.apache.cassandra.cql.jdbc.Connection connection;
+ protected org.apache.cassandra.cql.jdbc.Connection connection;
/** The cql. */
- protected final String cql;
+ protected String cql;
+
+ protected int fetchDirection = ResultSet.FETCH_FORWARD;
+
+ protected int fetchSize = 0;
- /**
- * Constructor using fields.
- * @param con cassandra connection.
- */
- CassandraStatement(org.apache.cassandra.cql.jdbc.Connection con)
+ protected int maxFieldSize = 0;
+
+ protected int maxRows = 0;
+
+ protected int resultSetType = ResultSet.TYPE_FORWARD_ONLY;
+
+ protected int resultSetConcurrency = ResultSet.TYPE_FORWARD_ONLY;
+
+ protected int resultSetHoldability = ResultSet.HOLD_CURSORS_OVER_COMMIT;
+
+ protected ResultSet currentResultSet = null;
+
+ protected int updateCount = -1;
+
+ protected boolean escapeProcessing = true;
+
+ CassandraStatement(org.apache.cassandra.cql.jdbc.Connection con) throws SQLException
{
this(con, null);
}
- /**
- * Constructor using fields.
- *
- * @param con cassandra connection
- * @param cql the cql
- */
- CassandraStatement(org.apache.cassandra.cql.jdbc.Connection con, String cql)
+ CassandraStatement(org.apache.cassandra.cql.jdbc.Connection con, String cql) throws SQLException
{
this.connection = con;
this.cql = cql;
}
-
- /**
- * @param iface
- * @return
- * @throws SQLException
- */
- public boolean isWrapperFor(Class<?> iface) throws SQLException
+ CassandraStatement(org.apache.cassandra.cql.jdbc.Connection con, String cql, int resultSetType, int resultSetConcurrency) throws SQLException
{
- throw new UnsupportedOperationException("method not supported");
+ this(con,cql,resultSetType,resultSetConcurrency, ResultSet.HOLD_CURSORS_OVER_COMMIT);
}
- /**
- * @param <T>
- * @param iface
- * @return
- * @throws SQLException
- */
- public <T> T unwrap(Class<T> iface) throws SQLException
+ CassandraStatement(org.apache.cassandra.cql.jdbc.Connection con, String cql, int resultSetType, int resultSetConcurrency,
+ int resultSetHoldability) throws SQLException
{
- throw new UnsupportedOperationException("method not supported");
- }
+ this.connection = con;
+ this.cql = cql;
+
+ if (!(resultSetType == ResultSet.TYPE_FORWARD_ONLY
+ || resultSetType == ResultSet.TYPE_SCROLL_INSENSITIVE
+ || resultSetType == ResultSet.TYPE_SCROLL_SENSITIVE)) throw new SQLSyntaxErrorException(BAD_TYPE_RSET);
+ this.resultSetType = resultSetType;
+
+ if (!(resultSetConcurrency == ResultSet.CONCUR_READ_ONLY
+ || resultSetConcurrency == ResultSet.CONCUR_UPDATABLE )) throw new SQLSyntaxErrorException(BAD_TYPE_RSET);
+ this.resultSetConcurrency = resultSetConcurrency;
+
+ if (!(resultSetHoldability == ResultSet.HOLD_CURSORS_OVER_COMMIT
+ || resultSetHoldability == ResultSet.CLOSE_CURSORS_AT_COMMIT)) throw new SQLSyntaxErrorException(BAD_HOLD_RSET);
+ this.resultSetHoldability = resultSetHoldability;
+ }
- /**
- * @param arg0
- * @throws SQLException
- */
public void addBatch(String arg0) throws SQLException
{
- throw new UnsupportedOperationException("method not supported");
-
+ checkNotClosed();
+ throw new SQLFeatureNotSupportedException(NO_BATCH);
}
-
- /**
- * @throws SQLException
- */
- public void cancel() throws SQLException
+ private final void checkNotClosed() throws SQLException
{
- throw new UnsupportedOperationException("method not supported");
-
+ if (isClosed()) throw new SQLRecoverableException(WAS_CLOSED_STMT);
}
-
- /**
- * @throws SQLException
- */
public void clearBatch() throws SQLException
{
- throw new UnsupportedOperationException("method not supported");
-
+ checkNotClosed();
+ throw new SQLFeatureNotSupportedException(NO_BATCH);
}
-
- /**
- * @throws SQLException
- */
public void clearWarnings() throws SQLException
{
- throw new UnsupportedOperationException("method not supported");
-
+ // This implementation does not support the collection of warnings so clearing is a no-op
+ // but it is still an exception to call this on a closed connection.
+ checkNotClosed();
}
-
- /**
- * This is a no-op.
- * @throws SQLException
- */
public void close() throws SQLException
{
+ connection = null;
+ cql = null;
}
-
- /**
- * @param query
- * @return
- * @throws SQLException
- */
- public boolean execute(String query) throws SQLException
+ private void doExecute(String sql) throws SQLException
{
try
{
- return connection.execute(query) != null;
+ resetResults();
+ CqlResult rSet = connection.execute(sql);
+
+ switch(rSet.getType())
+ {
+ case ROWS:
+ currentResultSet = new CResultSet(this,rSet, connection.decoder, connection.curKeyspace, connection.curColumnFamily);
+ break;
+ case INT:
+ updateCount = rSet.getNum();
+ break;
+ case VOID:
+ updateCount = 0;
+ break;
+ }
}
catch (InvalidRequestException e)
{
- throw new SQLException(e.getWhy());
+ throw new SQLSyntaxErrorException(e.getWhy());
}
catch (UnavailableException e)
{
- throw new SQLException("Cassandra was unavialable", e);
+ throw new SQLNonTransientConnectionException(NO_SERVER, e);
}
catch (TimedOutException e)
{
- throw new SQLException(e.getMessage());
+ throw new SQLTransientConnectionException(e.getMessage());
}
catch (SchemaDisagreementException e)
{
- throw new SQLException("schema does not match across nodes, (try again later).");
+ throw new SQLRecoverableException(SCHEMA_MISMATCH);
}
catch (TException e)
{
- throw new SQLException(e.getMessage());
+ throw new SQLNonTransientConnectionException(e.getMessage());
}
+
}
-
- /**
- * @param arg0
- * @param arg1
- * @return
- * @throws SQLException
- */
- public boolean execute(String arg0, int arg1) throws SQLException
+ public boolean execute(String query) throws SQLException
{
- throw new UnsupportedOperationException("method not supported");
+ checkNotClosed();
+ doExecute(query);
+ return !(currentResultSet==null);
}
-
-
- /**
- * @param arg0
- * @param arg1
- * @return
- * @throws SQLException
- */
- public boolean execute(String arg0, int[] arg1) throws SQLException
+ public boolean execute(String sql, int autoGeneratedKeys) throws SQLException
{
- throw new UnsupportedOperationException("method not supported");
+ checkNotClosed();
+
+ if (!(autoGeneratedKeys==RETURN_GENERATED_KEYS || autoGeneratedKeys==NO_GENERATED_KEYS))
+ throw new SQLSyntaxErrorException(BAD_AUTO_GEN);
+
+ if (autoGeneratedKeys==RETURN_GENERATED_KEYS) throw new SQLFeatureNotSupportedException(NO_GEN_KEYS);
+
+ return execute(sql);
}
-
- /**
- * @param arg0
- * @param arg1
- * @return
- * @throws SQLException
- */
- public boolean execute(String arg0, String[] arg1) throws SQLException
- {
- throw new UnsupportedOperationException("method not supported");
- }
-
-
- /**
- * @return
- * @throws SQLException
- */
public int[] executeBatch() throws SQLException
{
- throw new UnsupportedOperationException("method not supported");
+ throw new SQLFeatureNotSupportedException(NO_BATCH);
}
-
- /**
- * @param query
- * @return
- * @throws SQLException
- */
public ResultSet executeQuery(String query) throws SQLException
{
- try
- {
- CqlResult rSet = connection.execute(query);
- // todo: encapsulate.
- return new CResultSet(rSet, connection.decoder, connection.curKeyspace, connection.curColumnFamily);
- }
- catch (InvalidRequestException e)
- {
- throw new SQLException(e.getWhy());
- }
- catch (UnavailableException e)
- {
- throw new SQLException(e.getMessage());
- }
- catch (TimedOutException e)
- {
- throw new SQLException(e.getMessage());
- }
- catch (SchemaDisagreementException e)
- {
- throw new SQLException("schema does not match across nodes, (try again later).");
- }
- catch (TException e)
- {
- throw new SQLException(e.getMessage());
- }
+ checkNotClosed();
+ doExecute(query);
+ return currentResultSet;
}
- /**
- * @param query
- * @return
- * @throws SQLException
- */
public int executeUpdate(String query) throws SQLException
{
+ checkNotClosed();
if (!UpdatePattern.matcher(query).matches())
- throw new SQLException("Not an update statement.");
- try
- {
- CqlResult rSet = connection.execute(query);
- assert rSet.getType().equals(CqlResultType.VOID);
- // if only we knew how many rows were updated.
- return 0;
- }
- catch (InvalidRequestException e)
- {
- throw new SQLException(e.getWhy());
- }
- catch (UnavailableException e)
- {
- throw new SQLException(e.getMessage());
- }
- catch (TimedOutException e)
- {
- throw new SQLException(e.getMessage());
- }
- catch (SchemaDisagreementException e)
- {
- throw new SQLException("schema does not match across nodes, (try again later).");
- }
- catch (TException e)
- {
- throw new SQLException(e.getMessage());
- }
- }
-
-
- /**
- * @param arg0
- * @param arg1
- * @return
- * @throws SQLException
- */
- public int executeUpdate(String arg0, int arg1) throws SQLException
- {
- throw new UnsupportedOperationException("method not supported");
- }
-
-
- /**
- * @param arg0
- * @param arg1
- * @return
- * @throws SQLException
- */
- public int executeUpdate(String arg0, int[] arg1) throws SQLException
- {
- throw new UnsupportedOperationException("method not supported");
+ throw new SQLSyntaxErrorException("Not an update statement.");
+
+ doExecute(query);
+ return updateCount;
}
-
- /**
- * @param arg0
- * @param arg1
- * @return
- * @throws SQLException
- */
- public int executeUpdate(String arg0, String[] arg1) throws SQLException
- {
- throw new UnsupportedOperationException("method not supported");
+ public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException
+ {
+ checkNotClosed();
+
+ if (!(autoGeneratedKeys==RETURN_GENERATED_KEYS || autoGeneratedKeys==NO_GENERATED_KEYS)) throw new SQLFeatureNotSupportedException(BAD_AUTO_GEN);
+
+ return executeUpdate(sql);
}
-
- /**
- * @return
- * @throws SQLException
- */
public Connection getConnection() throws SQLException
{
- throw new UnsupportedOperationException("method not supported");
+ checkNotClosed();
+ return (Connection) connection;
}
-
- /**
- * @return
- * @throws SQLException
- */
public int getFetchDirection() throws SQLException
{
- throw new UnsupportedOperationException("method not supported");
+ checkNotClosed();
+ return fetchDirection;
}
-
- /**
- * @return
- * @throws SQLException
- */
public int getFetchSize() throws SQLException
{
- throw new UnsupportedOperationException("method not supported");
- }
-
-
- /**
- * @return
- * @throws SQLException
- */
- public ResultSet getGeneratedKeys() throws SQLException
- {
- throw new UnsupportedOperationException("method not supported");
+ checkNotClosed();
+ return fetchSize;
}
-
- /**
- * @return
- * @throws SQLException
- */
public int getMaxFieldSize() throws SQLException
{
- throw new UnsupportedOperationException("method not supported");
+ checkNotClosed();
+ return maxFieldSize;
}
-
- /**
- * @return
- * @throws SQLException
- */
public int getMaxRows() throws SQLException
{
- throw new UnsupportedOperationException("method not supported");
+ checkNotClosed();
+ return maxRows;
}
-
- /**
- * @return
- * @throws SQLException
- */
public boolean getMoreResults() throws SQLException
{
- throw new UnsupportedOperationException("method not supported");
- }
-
-
- /**
- * @param arg0
- * @return
- * @throws SQLException
- */
- public boolean getMoreResults(int arg0) throws SQLException
- {
- throw new UnsupportedOperationException("method not supported");
+ checkNotClosed();
+ resetResults();
+ // in the current Cassandra implementation there are never MORE results
+ return false;
+ }
+
+ public boolean getMoreResults(int current) throws SQLException
+ {
+ checkNotClosed();
+
+ switch (current)
+ {
+ case CLOSE_CURRENT_RESULT:
+ resetResults();
+ break;
+
+ case CLOSE_ALL_RESULTS:
+ case KEEP_CURRENT_RESULT:
+ throw new SQLFeatureNotSupportedException(NO_MULTIPLE);
+
+ default:
+ throw new SQLSyntaxErrorException(String.format(BAD_KEEP_RSET, current));
+ }
+ // in the current Cassandra implementation there are never MORE results
+ return false;
}
-
- /**
- * @return
- * @throws SQLException
- */
public int getQueryTimeout() throws SQLException
{
- throw new UnsupportedOperationException("method not supported");
+ // the Cassandra implementation does not support timeouts on queries
+ return 0;
}
-
- /**
- * @return
- * @throws SQLException
- */
public ResultSet getResultSet() throws SQLException
{
- throw new UnsupportedOperationException("method not supported");
+ checkNotClosed();
+ return currentResultSet;
}
-
- /**
- * @return
- * @throws SQLException
- */
public int getResultSetConcurrency() throws SQLException
{
- throw new UnsupportedOperationException("method not supported");
+ checkNotClosed();
+ return ResultSet.CONCUR_READ_ONLY;
}
-
- /**
- * @return
- * @throws SQLException
- */
public int getResultSetHoldability() throws SQLException
{
- throw new UnsupportedOperationException("method not supported");
- }
-
+ checkNotClosed();
+ // the Cassandra implementations does not support commits so this is the closest match
+ return ResultSet.HOLD_CURSORS_OVER_COMMIT;
+ }
- /**
- * @return
- * @throws SQLException
- */
public int getResultSetType() throws SQLException
{
- throw new UnsupportedOperationException("method not supported");
+ checkNotClosed();
+ return ResultSet.TYPE_FORWARD_ONLY;
}
-
- /**
- * @return
- * @throws SQLException
- */
public int getUpdateCount() throws SQLException
{
- throw new UnsupportedOperationException("method not supported");
+ checkNotClosed();
+ return updateCount;
}
-
- /**
- * @return
- * @throws SQLException
- */
public SQLWarning getWarnings() throws SQLException
{
- throw new UnsupportedOperationException("method not supported");
+ checkNotClosed();
+ return null;
}
-
- /**
- * @return
- * @throws SQLException
- */
public boolean isClosed() throws SQLException
{
- throw new UnsupportedOperationException("method not supported");
+ return connection==null;
}
-
- /**
- * @return
- * @throws SQLException
- */
public boolean isPoolable() throws SQLException
{
- throw new UnsupportedOperationException("method not supported");
+ checkNotClosed();
+ return false;
}
+ public boolean isWrapperFor(Class<?> iface) throws SQLException
+ {
+ return false;
+ }
- /**
- * @param arg0
- * @throws SQLException
- */
- public void setCursorName(String arg0) throws SQLException
+ private final void resetResults()
{
- throw new UnsupportedOperationException("method not supported");
-
+ currentResultSet = null;
+ updateCount = -1;
}
-
- /**
- * @param arg0
- * @throws SQLException
- */
- public void setEscapeProcessing(boolean arg0) throws SQLException
+ public void setEscapeProcessing(boolean enable) throws SQLException
{
- throw new UnsupportedOperationException("method not supported");
-
+ checkNotClosed();
+ // the Cassandra implementation does not currently look at this
+ escapeProcessing = enable;
}
-
- /**
- * @param arg0
- * @throws SQLException
- */
- public void setFetchDirection(int arg0) throws SQLException
+ public void setFetchDirection(int direction) throws SQLException
{
- throw new UnsupportedOperationException("method not supported");
+ checkNotClosed();
+ if (direction == ResultSet.FETCH_FORWARD || direction == ResultSet.FETCH_REVERSE || direction == ResultSet.FETCH_UNKNOWN)
+ {
+ if ((getResultSetType() == ResultSet.TYPE_FORWARD_ONLY) && (direction != ResultSet.FETCH_FORWARD))
+ throw new SQLSyntaxErrorException(String.format(BAD_FETCH_DIR, direction));
+ fetchDirection = direction;
+ }
+ throw new SQLSyntaxErrorException(String.format(BAD_FETCH_DIR, direction));
}
-
- /**
- * @param arg0
- * @throws SQLException
- */
- public void setFetchSize(int arg0) throws SQLException
+
+ public void setFetchSize(int size) throws SQLException
{
- throw new UnsupportedOperationException("method not supported");
-
+ checkNotClosed();
+ if (size < 0 ) throw new SQLSyntaxErrorException(String.format(BAD_FETCH_SIZE, size));
+ fetchSize = size;
}
-
- /**
- * @param arg0
- * @throws SQLException
- */
public void setMaxFieldSize(int arg0) throws SQLException
{
- throw new UnsupportedOperationException("method not supported");
-
+ checkNotClosed();
+ // silently ignore this setting. always use default 0 (unlimited)
}
-
- /**
- * @param arg0
- * @throws SQLException
- */
public void setMaxRows(int arg0) throws SQLException
{
- throw new UnsupportedOperationException("method not supported");
-
+ checkNotClosed();
+ // silently ignore this setting. always use default 0 (unlimited)
}
-
- /**
- * @param arg0
- * @throws SQLException
- */
- public void setPoolable(boolean arg0) throws SQLException
+ public void setPoolable(boolean poolable) throws SQLException
{
- throw new UnsupportedOperationException("method not supported");
-
+ checkNotClosed();
+ // silently ignore any attempt to set this away from the current default (false)
}
-
- /**
- * @param arg0
- * @throws SQLException
- */
public void setQueryTimeout(int arg0) throws SQLException
{
- throw new UnsupportedOperationException("method not supported");
-
+ checkNotClosed();
+ // silently ignore any attempt to set this away from the current default (0)
+ }
+
+ public <T> T unwrap(Class<T> iface) throws SQLException
+ {
+ throw new SQLFeatureNotSupportedException(String.format(NO_INTERFACE, iface.getSimpleName()));
}
}
Modified: cassandra/drivers/java/src/org/apache/cassandra/cql/jdbc/ColumnDecoder.java
URL: http://svn.apache.org/viewvc/cassandra/drivers/java/src/org/apache/cassandra/cql/jdbc/ColumnDecoder.java?rev=1137231&r1=1137230&r2=1137231&view=diff
==============================================================================
--- cassandra/drivers/java/src/org/apache/cassandra/cql/jdbc/ColumnDecoder.java (original)
+++ cassandra/drivers/java/src/org/apache/cassandra/cql/jdbc/ColumnDecoder.java Sat Jun 18 19:19:13 2011
@@ -29,8 +29,8 @@ import org.apache.cassandra.db.marshal.A
import org.apache.cassandra.thrift.*;
import org.apache.cassandra.utils.ByteBufferUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+//import org.slf4j.Logger;
+//import org.slf4j.LoggerFactory;
import java.nio.ByteBuffer;
import java.nio.charset.CharacterCodingException;
@@ -43,7 +43,7 @@ import java.util.Map;
*/
class ColumnDecoder
{
- private static final Logger logger = LoggerFactory.getLogger(ColumnDecoder.class);
+// private static final Logger logger = LoggerFactory.getLogger(ColumnDecoder.class);
private final Map<String, CFMetaData> metadata = new HashMap<String, CFMetaData>();
@@ -72,14 +72,14 @@ class ColumnDecoder
}
}
- AbstractType getComparator(String keyspace, String columnFamily)
+ AbstractType<?> getComparator(String keyspace, String columnFamily)
{
- return metadata.get(String.format("%s.%s", keyspace, columnFamily)).comparator;
+ CFMetaData md = metadata.get(String.format("%s.%s", keyspace, columnFamily));
+ return (md == null) ? null : md.comparator;
}
- AbstractType getNameType(String keyspace, String columnFamily, ByteBuffer name)
+ AbstractType<?> getNameType(String keyspace, String columnFamily, ByteBuffer name)
{
-
CFMetaData md = metadata.get(String.format("%s.%s", keyspace, columnFamily));
try
{
@@ -93,7 +93,7 @@ class ColumnDecoder
return md.comparator;
}
- AbstractType getValueType(String keyspace, String columnFamily, ByteBuffer name)
+ AbstractType<?> getValueType(String keyspace, String columnFamily, ByteBuffer name)
{
CFMetaData md = metadata.get(String.format("%s.%s", keyspace, columnFamily));
try
@@ -109,15 +109,16 @@ class ColumnDecoder
return cd == null ? md.getDefaultValidator() : cd.getValidator();
}
- public AbstractType getKeyValidator(String keyspace, String columnFamily)
+ public AbstractType<?> getKeyValidator(String keyspace, String columnFamily)
{
- return metadata.get(String.format("%s.%s", keyspace, columnFamily)).getKeyValidator();
+ CFMetaData md = metadata.get(String.format("%s.%s", keyspace, columnFamily));
+ return (md == null) ? null : md.getKeyValidator();
}
/** uses the AbstractType to map a column name to a string. */
public String colNameAsString(String keyspace, String columnFamily, ByteBuffer name)
{
- AbstractType comparator = getNameType(keyspace, columnFamily, name);
+ AbstractType<?> comparator = getNameType(keyspace, columnFamily, name);
return comparator.getString(name);
}
Modified: cassandra/drivers/java/src/org/apache/cassandra/cql/jdbc/Connection.java
URL: http://svn.apache.org/viewvc/cassandra/drivers/java/src/org/apache/cassandra/cql/jdbc/Connection.java?rev=1137231&r1=1137230&r2=1137231&view=diff
==============================================================================
--- cassandra/drivers/java/src/org/apache/cassandra/cql/jdbc/Connection.java (original)
+++ cassandra/drivers/java/src/org/apache/cassandra/cql/jdbc/Connection.java Sat Jun 18 19:19:13 2011
@@ -104,6 +104,8 @@ class Connection
this(hostName, portNo);
Map<String, String> credentials = new HashMap<String, String>();
+ if (userName != null) credentials.put("username", userName);
+ if (password != null) credentials.put("password", password);
AuthenticationRequest areq = new AuthenticationRequest(credentials);
client.login(areq) ;
}
Modified: cassandra/drivers/java/src/org/apache/cassandra/cql/jdbc/TypedColumn.java
URL: http://svn.apache.org/viewvc/cassandra/drivers/java/src/org/apache/cassandra/cql/jdbc/TypedColumn.java?rev=1137231&r1=1137230&r2=1137231&view=diff
==============================================================================
--- cassandra/drivers/java/src/org/apache/cassandra/cql/jdbc/TypedColumn.java (original)
+++ cassandra/drivers/java/src/org/apache/cassandra/cql/jdbc/TypedColumn.java Sat Jun 18 19:19:13 2011
@@ -24,7 +24,6 @@ package org.apache.cassandra.cql.jdbc;
import org.apache.cassandra.db.marshal.AbstractType;
import org.apache.cassandra.thrift.Column;
-import java.nio.ByteBuffer;
public class TypedColumn
{
@@ -35,9 +34,9 @@ public class TypedColumn
// (a good example is byte buffers).
private final Object value;
private final String nameString;
- private final AbstractType nameType, valueType;
+ private final AbstractType<?> nameType, valueType;
- public TypedColumn(Column column, AbstractType comparator, AbstractType validator)
+ public TypedColumn(Column column, AbstractType<?> comparator, AbstractType<?> validator)
{
rawColumn = column;
this.value = column.value == null ? null : validator.compose(column.value);
Modified: cassandra/drivers/java/src/org/apache/cassandra/cql/jdbc/Utils.java
URL: http://svn.apache.org/viewvc/cassandra/drivers/java/src/org/apache/cassandra/cql/jdbc/Utils.java?rev=1137231&r1=1137230&r2=1137231&view=diff
==============================================================================
--- cassandra/drivers/java/src/org/apache/cassandra/cql/jdbc/Utils.java (original)
+++ cassandra/drivers/java/src/org/apache/cassandra/cql/jdbc/Utils.java Sat Jun 18 19:19:13 2011
@@ -23,23 +23,43 @@ package org.apache.cassandra.cql.jdbc;
import java.io.ByteArrayOutputStream;
import java.nio.ByteBuffer;
-import java.sql.SQLException;
-import java.sql.Types;
-import java.util.UUID;
import java.util.zip.Deflater;
import com.google.common.base.Charsets;
-import org.apache.cassandra.db.marshal.AbstractType;
-import org.apache.cassandra.db.marshal.BytesType;
-import org.apache.cassandra.db.marshal.IntegerType;
-import org.apache.cassandra.db.marshal.LongType;
import org.apache.cassandra.thrift.Compression;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
class Utils
{
- private static final Logger logger = LoggerFactory.getLogger(Utils.class);
+ protected static final String PROTOCOL = "jdbc:cassandra:";
+ protected static final String WAS_CLOSED_CON = "method was called on a closed Connection";
+ protected static final String WAS_CLOSED_STMT = "method was called on a closed Statement";
+ protected static final String WAS_CLOSED_RSLT = "method was called on a closed ResultSet";
+ protected static final String NO_INTERFACE = "no object was found that matched the provided interface: %s";
+ protected static final String NO_TRANSACTIONS = "the Cassandra implementation does not support transactions";
+ protected static final String NO_SERVER = "no Cassandra server is available";
+ protected static final String ALWAYS_AUTOCOMMIT = "the Cassandra implementation is always in auto-commit mode";
+ protected static final String BAD_TIMEOUT = "the timeout value was less than zero";
+ protected static final String SCHEMA_MISMATCH = "schema does not match across nodes, (try again later)";
+ protected static final String NOT_SUPPORTED = "the Cassandra implementation does not support this method";
+ protected static final String NO_GEN_KEYS = "the Cassandra implementation does not currently support returning generated keys";
+ protected static final String NO_BATCH = "the Cassandra implementation does not currently support this batch in Statement";
+ protected static final String NO_MULTIPLE = "the Cassandra implementation does not currently support multiple open Result Sets";
+ protected static final String BAD_KEEP_RSET = "the argument for keeping the current result set : %s is not a valid value";
+ protected static final String BAD_TYPE_RSET = "the argument for result set type : %s is not a valid value";
+ protected static final String BAD_CONCUR_RSET = "the argument for result set concurrency : %s is not a valid value";
+ protected static final String BAD_HOLD_RSET = "the argument for result set holdability : %s is not a valid value";
+ protected static final String BAD_FETCH_DIR = "fetch direction value of : %s is illegal";
+ protected static final String BAD_AUTO_GEN = "auto key generation value of : %s is illegal";
+ protected static final String BAD_FETCH_SIZE = "fetch size of : %s rows may not be negative";
+ protected static final String MUST_BE_POSITIVE = "index must be a positive number less or equal the count of returned columns: %s";
+ protected static final String VALID_LABELS = "name provided was not in the list of valid column labels: %s";
+ protected static final String NOT_TRANSLATABLE = "column was stored in %s format which is not translatable to %s";
+ protected static final String NOT_BOOLEAN = "string value was neither 'true' nor 'false' : %s";
+
+
+ protected static final Logger logger = LoggerFactory.getLogger(Utils.class);
public static ByteBuffer compressQuery(String queryStr, Compression compression)
{