cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eev...@apache.org
Subject svn commit: r1069593 [2/2] - in /cassandra/trunk: ./ drivers/java/src/org/apache/cassandra/cql/driver/jdbc/ drivers/java/test/
Date Thu, 10 Feb 2011 22:34:05 GMT
Added: cassandra/trunk/drivers/java/src/org/apache/cassandra/cql/driver/jdbc/CassandraStatement.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/drivers/java/src/org/apache/cassandra/cql/driver/jdbc/CassandraStatement.java?rev=1069593&view=auto
==============================================================================
--- cassandra/trunk/drivers/java/src/org/apache/cassandra/cql/driver/jdbc/CassandraStatement.java
(added)
+++ cassandra/trunk/drivers/java/src/org/apache/cassandra/cql/driver/jdbc/CassandraStatement.java
Thu Feb 10 22:34:05 2011
@@ -0,0 +1,1230 @@
+/*
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ */
+package org.apache.cassandra.cql.driver.jdbc;
+
+import java.io.InputStream;
+import java.io.Reader;
+import java.math.BigDecimal;
+import java.net.URL;
+import java.sql.Array;
+import java.sql.Blob;
+import java.sql.Clob;
+import java.sql.Connection;
+import java.sql.Date;
+import java.sql.NClob;
+import java.sql.ParameterMetaData;
+import java.sql.PreparedStatement;
+import java.sql.Ref;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.RowId;
+import java.sql.SQLException;
+import java.sql.SQLWarning;
+import java.sql.SQLXML;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.util.Calendar;
+
+import org.apache.cassandra.thrift.CqlResult;
+import org.apache.cassandra.thrift.InvalidRequestException;
+import org.apache.cassandra.thrift.TimedOutException;
+import org.apache.cassandra.thrift.UnavailableException;
+import org.apache.thrift.TException;
+
+/**
+ * Cassandra statement: implementation class for {@link PreparedStatement}.
+ */
+
+class CassandraStatement implements PreparedStatement
+{
+    
+    /** The connection. */
+    private org.apache.cassandra.cql.driver.Connection connection;
+    
+    /** The cql. */
+    private String cql;
+
+    /**
+     * Constructor using fields.
+     * @param con     cassandra connection.
+     */
+    CassandraStatement(org.apache.cassandra.cql.driver.Connection con)
+    {
+        this.connection = con;
+    }
+
+    /**
+     * Constructor using fields.
+     *
+     * @param con     cassandra connection
+     * @param cql the cql
+     */
+    CassandraStatement(org.apache.cassandra.cql.driver.Connection con, String cql)
+    {
+        this.connection = con;
+        this.cql = cql;
+    }
+
+    
+    /**
+     * @param iface
+     * @return
+     * @throws SQLException
+     */
+    public boolean isWrapperFor(Class<?> iface) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+    }
+    
+    /**
+     * @param <T>
+     * @param iface
+     * @return
+     * @throws SQLException
+     */
+    public <T> T unwrap(Class<T> iface) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+    }
+
+    
+    /**
+     * @param arg0
+     * @throws SQLException
+     */
+    public void addBatch(String arg0) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @throws SQLException
+     */
+    public void cancel() throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @throws SQLException
+     */
+    public void clearBatch() throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @throws SQLException
+     */
+    public void clearWarnings() throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @throws SQLException
+     */
+    public void close() throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @param query
+     * @return
+     * @throws SQLException
+     */
+    public boolean execute(String query) throws SQLException
+    {
+        try
+        {
+            return connection.execute(query) != null;
+        } 
+        catch (InvalidRequestException e)
+        {
+            throw new SQLException(e.getMessage());
+        }
+        catch (UnavailableException e)
+        {
+            throw new SQLException(e.getMessage());
+        }
+        catch (TimedOutException e)
+        {
+            throw new SQLException(e.getMessage());
+        }
+        catch (TException e)
+        {
+            throw new SQLException(e.getMessage());
+        }
+    }
+
+    
+    /**
+     * @param arg0
+     * @param arg1
+     * @return
+     * @throws SQLException
+     */
+    public boolean execute(String arg0, int arg1) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+    }
+
+    
+    /**
+     * @param arg0
+     * @param arg1
+     * @return
+     * @throws SQLException
+     */
+    public boolean execute(String arg0, int[] arg1) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+    }
+
+    
+    /**
+     * @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");
+    }
+
+    
+    /**
+     * @param query
+     * @return
+     * @throws SQLException
+     */
+    public ResultSet executeQuery(String query) throws SQLException
+    {
+        try
+        {
+            CqlResult rSet = connection.execute(query);
+            return new CassandraResultSet(rSet);
+        }
+        catch (InvalidRequestException e)
+        {
+            throw new SQLException(e.getMessage());
+        }
+        catch (UnavailableException e)
+        {
+            throw new SQLException(e.getMessage());
+        }
+        catch (TimedOutException e)
+        {
+            throw new SQLException(e.getMessage());
+        }
+        catch (TException e)
+        {
+            throw new SQLException(e.getMessage());
+        }
+    }
+
+    
+    /**
+     * @param arg0
+     * @return
+     * @throws SQLException
+     */
+    public int executeUpdate(String arg0) 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");
+    }
+
+    
+    /**
+     * @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, String[] arg1) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+    }
+
+    
+    /**
+     * @return
+     * @throws SQLException
+     */
+    public Connection getConnection() throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+    }
+
+    
+    /**
+     * @return
+     * @throws SQLException
+     */
+    public int getFetchDirection() throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+    }
+
+    
+    /**
+     * @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");
+    }
+
+    
+    /**
+     * @return
+     * @throws SQLException
+     */
+    public int getMaxFieldSize() throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+    }
+
+    
+    /**
+     * @return
+     * @throws SQLException
+     */
+    public int getMaxRows() throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+    }
+
+    
+    /**
+     * @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");
+    }
+
+    
+    /**
+     * @return
+     * @throws SQLException
+     */
+    public int getQueryTimeout() throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+    }
+
+    
+    /**
+     * @return
+     * @throws SQLException
+     */
+    public ResultSet getResultSet() throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+    }
+
+    
+    /**
+     * @return
+     * @throws SQLException
+     */
+    public int getResultSetConcurrency() throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+    }
+
+    
+    /**
+     * @return
+     * @throws SQLException
+     */
+    public int getResultSetHoldability() throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+    }
+
+    
+    /**
+     * @return
+     * @throws SQLException
+     */
+    public int getResultSetType() throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+    }
+
+    
+    /**
+     * @return
+     * @throws SQLException
+     */
+    public int getUpdateCount() throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+    }
+
+    
+    /**
+     * @return
+     * @throws SQLException
+     */
+    public SQLWarning getWarnings() throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+    }
+
+    
+    /**
+     * @return
+     * @throws SQLException
+     */
+    public boolean isClosed() throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+    }
+
+    
+    /**
+     * @return
+     * @throws SQLException
+     */
+    public boolean isPoolable() throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+    }
+
+    
+    /**
+     * @param arg0
+     * @throws SQLException
+     */
+    public void setCursorName(String arg0) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @param arg0
+     * @throws SQLException
+     */
+    public void setEscapeProcessing(boolean arg0) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @param arg0
+     * @throws SQLException
+     */
+    public void setFetchDirection(int arg0) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @param arg0
+     * @throws SQLException
+     */
+    public void setFetchSize(int arg0) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @param arg0
+     * @throws SQLException
+     */
+    public void setMaxFieldSize(int arg0) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @param arg0
+     * @throws SQLException
+     */
+    public void setMaxRows(int arg0) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @param arg0
+     * @throws SQLException
+     */
+    public void setPoolable(boolean arg0) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @param arg0
+     * @throws SQLException
+     */
+    public void setQueryTimeout(int arg0) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @throws SQLException
+     */
+    public void addBatch() throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @throws SQLException
+     */
+    public void clearParameters() throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @return
+     * @throws SQLException
+     */
+    public boolean execute() throws SQLException
+    {
+        return this.cql != null ? execute(cql) : false;
+    }
+
+    
+    /**
+     * @return
+     * @throws SQLException
+     */
+    public ResultSet executeQuery() throws SQLException
+    {
+        return this.cql != null ? executeQuery(cql) : null;
+    }
+
+    
+    /**
+     * @return
+     * @throws SQLException
+     */
+    public int executeUpdate() throws SQLException
+    {
+        return 0;
+    }
+
+    
+    /**
+     * @return
+     * @throws SQLException
+     */
+    public ResultSetMetaData getMetaData() throws SQLException
+    {
+        return null;
+    }
+
+    
+    /**
+     * @return
+     * @throws SQLException
+     */
+    public ParameterMetaData getParameterMetaData() throws SQLException
+    {
+        return null;
+    }
+
+    
+    /**
+     * @param parameterIndex
+     * @param x
+     * @throws SQLException
+     */
+    public void setArray(int parameterIndex, Array x) throws SQLException
+    {
+    }
+
+    
+    /**
+     * @param parameterIndex
+     * @param x
+     * @throws SQLException
+     */
+    public void setAsciiStream(int parameterIndex, InputStream x) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @param parameterIndex
+     * @param x
+     * @param length
+     * @throws SQLException
+     */
+    public void setAsciiStream(int parameterIndex, InputStream x, int length) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @param parameterIndex
+     * @param x
+     * @param length
+     * @throws SQLException
+     */
+    public void setAsciiStream(int parameterIndex, InputStream x, long length) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @param parameterIndex
+     * @param x
+     * @throws SQLException
+     */
+    public void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @param parameterIndex
+     * @param x
+     * @throws SQLException
+     */
+    public void setBinaryStream(int parameterIndex, InputStream x) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @param parameterIndex
+     * @param x
+     * @param length
+     * @throws SQLException
+     */
+    public void setBinaryStream(int parameterIndex, InputStream x, int length) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @param parameterIndex
+     * @param x
+     * @param length
+     * @throws SQLException
+     */
+    public void setBinaryStream(int parameterIndex, InputStream x, long length) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @param parameterIndex
+     * @param x
+     * @throws SQLException
+     */
+    public void setBlob(int parameterIndex, Blob x) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @param parameterIndex
+     * @param inputStream
+     * @throws SQLException
+     */
+    public void setBlob(int parameterIndex, InputStream inputStream) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @param parameterIndex
+     * @param inputStream
+     * @param length
+     * @throws SQLException
+     */
+    public void setBlob(int parameterIndex, InputStream inputStream, long length) throws
SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @param parameterIndex
+     * @param x
+     * @throws SQLException
+     */
+    public void setBoolean(int parameterIndex, boolean x) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @param parameterIndex
+     * @param x
+     * @throws SQLException
+     */
+    public void setByte(int parameterIndex, byte x) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @param parameterIndex
+     * @param x
+     * @throws SQLException
+     */
+    public void setBytes(int parameterIndex, byte[] x) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @param parameterIndex
+     * @param reader
+     * @throws SQLException
+     */
+    public void setCharacterStream(int parameterIndex, Reader reader) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @param parameterIndex
+     * @param reader
+     * @param length
+     * @throws SQLException
+     */
+    public void setCharacterStream(int parameterIndex, Reader reader, int length) throws
SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @param parameterIndex
+     * @param reader
+     * @param length
+     * @throws SQLException
+     */
+    public void setCharacterStream(int parameterIndex, Reader reader, long length) throws
SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @param parameterIndex
+     * @param x
+     * @throws SQLException
+     */
+    public void setClob(int parameterIndex, Clob x) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @param parameterIndex
+     * @param reader
+     * @throws SQLException
+     */
+    public void setClob(int parameterIndex, Reader reader) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @param parameterIndex
+     * @param reader
+     * @param length
+     * @throws SQLException
+     */
+    public void setClob(int parameterIndex, Reader reader, long length) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @param parameterIndex
+     * @param x
+     * @throws SQLException
+     */
+    public void setDate(int parameterIndex, Date x) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @param parameterIndex
+     * @param x
+     * @param cal
+     * @throws SQLException
+     */
+    public void setDate(int parameterIndex, Date x, Calendar cal) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @param parameterIndex
+     * @param x
+     * @throws SQLException
+     */
+    public void setDouble(int parameterIndex, double x) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @param parameterIndex
+     * @param x
+     * @throws SQLException
+     */
+    public void setFloat(int parameterIndex, float x) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @param parameterIndex
+     * @param x
+     * @throws SQLException
+     */
+    public void setInt(int parameterIndex, int x) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @param parameterIndex
+     * @param x
+     * @throws SQLException
+     */
+    public void setLong(int parameterIndex, long x) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @param parameterIndex
+     * @param value
+     * @throws SQLException
+     */
+    public void setNCharacterStream(int parameterIndex, Reader value) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @param parameterIndex
+     * @param value
+     * @param length
+     * @throws SQLException
+     */
+    public void setNCharacterStream(int parameterIndex, Reader value, long length) throws
SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @param parameterIndex
+     * @param value
+     * @throws SQLException
+     */
+    public void setNClob(int parameterIndex, NClob value) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @param parameterIndex
+     * @param reader
+     * @throws SQLException
+     */
+    public void setNClob(int parameterIndex, Reader reader) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @param parameterIndex
+     * @param reader
+     * @param length
+     * @throws SQLException
+     */
+    public void setNClob(int parameterIndex, Reader reader, long length) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @param parameterIndex
+     * @param value
+     * @throws SQLException
+     */
+    public void setNString(int parameterIndex, String value) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @param parameterIndex
+     * @param sqlType
+     * @throws SQLException
+     */
+    public void setNull(int parameterIndex, int sqlType) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @param parameterIndex
+     * @param sqlType
+     * @param typeName
+     * @throws SQLException
+     */
+    public void setNull(int parameterIndex, int sqlType, String typeName) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @param parameterIndex
+     * @param x
+     * @throws SQLException
+     */
+    public void setObject(int parameterIndex, Object x) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @param parameterIndex
+     * @param x
+     * @param targetSqlType
+     * @throws SQLException
+     */
+    public void setObject(int parameterIndex, Object x, int targetSqlType) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @param parameterIndex
+     * @param x
+     * @param targetSqlType
+     * @param scaleOrLength
+     * @throws SQLException
+     */
+    public void setObject(int parameterIndex, Object x, int targetSqlType, int scaleOrLength)
throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @param parameterIndex
+     * @param x
+     * @throws SQLException
+     */
+    public void setRef(int parameterIndex, Ref x) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @param parameterIndex
+     * @param x
+     * @throws SQLException
+     */
+    public void setRowId(int parameterIndex, RowId x) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @param parameterIndex
+     * @param xmlObject
+     * @throws SQLException
+     */
+    public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @param parameterIndex
+     * @param x
+     * @throws SQLException
+     */
+    public void setShort(int parameterIndex, short x) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @param parameterIndex
+     * @param x
+     * @throws SQLException
+     */
+    public void setString(int parameterIndex, String x) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @param parameterIndex
+     * @param x
+     * @throws SQLException
+     */
+    public void setTime(int parameterIndex, Time x) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @param parameterIndex
+     * @param x
+     * @param cal
+     * @throws SQLException
+     */
+    public void setTime(int parameterIndex, Time x, Calendar cal) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+
+    }
+
+    
+    /**
+     * @param parameterIndex
+     * @param x
+     * @throws SQLException
+     */
+    public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+    }
+
+    
+    /**
+     * @param parameterIndex
+     * @param x
+     * @param cal
+     * @throws SQLException
+     */
+    public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+    }
+
+    
+    /**
+     * @param parameterIndex
+     * @param x
+     * @throws SQLException
+     */
+    public void setURL(int parameterIndex, URL x) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+    }
+
+    
+    /**
+     * @param parameterIndex
+     * @param x
+     * @param length
+     * @throws SQLException
+     */
+    public void setUnicodeStream(int parameterIndex, InputStream x, int length) throws SQLException
+    {
+        throw new UnsupportedOperationException("method not supported");
+    }
+
+}

Added: cassandra/trunk/drivers/java/src/org/apache/cassandra/cql/driver/jdbc/DriverResolverException.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/drivers/java/src/org/apache/cassandra/cql/driver/jdbc/DriverResolverException.java?rev=1069593&view=auto
==============================================================================
--- cassandra/trunk/drivers/java/src/org/apache/cassandra/cql/driver/jdbc/DriverResolverException.java
(added)
+++ cassandra/trunk/drivers/java/src/org/apache/cassandra/cql/driver/jdbc/DriverResolverException.java
Thu Feb 10 22:34:05 2011
@@ -0,0 +1,39 @@
+/*
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ */
+package org.apache.cassandra.cql.driver.jdbc;
+/**
+ * Runtime exception handling in case of runtime error during Driver resolving. 
+ */
+public class DriverResolverException extends RuntimeException {
+
+	/**
+	 * Default serial version UID. 
+	 */
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * Constructor using fields.
+	 * @param errMsg error message.
+	 */
+	public DriverResolverException(String errMsg) {
+		super(errMsg);
+	}
+}

Added: cassandra/trunk/drivers/java/src/org/apache/cassandra/cql/driver/jdbc/InvalidUrlException.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/drivers/java/src/org/apache/cassandra/cql/driver/jdbc/InvalidUrlException.java?rev=1069593&view=auto
==============================================================================
--- cassandra/trunk/drivers/java/src/org/apache/cassandra/cql/driver/jdbc/InvalidUrlException.java
(added)
+++ cassandra/trunk/drivers/java/src/org/apache/cassandra/cql/driver/jdbc/InvalidUrlException.java
Thu Feb 10 22:34:05 2011
@@ -0,0 +1,41 @@
+/*
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ */
+package org.apache.cassandra.cql.driver.jdbc;
+
+/**
+ * Runtime exception handling during incorrect connection url provided.
+ */
+public class InvalidUrlException extends RuntimeException {
+	
+	/**
+	 *  Default serial version UID
+	 */
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * Constructor using fields.
+	 * @param errMsg error message.
+	 */
+	public InvalidUrlException(String errMsg) {
+		super(errMsg);
+	}
+
+}

Added: cassandra/trunk/drivers/java/test/BaseTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/drivers/java/test/BaseTest.java?rev=1069593&view=auto
==============================================================================
--- cassandra/trunk/drivers/java/test/BaseTest.java (added)
+++ cassandra/trunk/drivers/java/test/BaseTest.java Thu Feb 10 22:34:05 2011
@@ -0,0 +1,78 @@
+
+import java.io.IOException;
+import java.net.Socket;
+import java.net.UnknownHostException;
+
+import junit.framework.TestCase;
+
+import org.apache.cassandra.config.CFMetaData;
+import org.apache.cassandra.config.ConfigurationException;
+import org.apache.cassandra.config.DatabaseDescriptor;
+import org.apache.cassandra.config.KSMetaData;
+import org.apache.cassandra.service.EmbeddedCassandraService;
+
+/**
+ * The abstract BaseClass.
+ */
+public abstract class BaseTest extends TestCase
+{
+
+    /** The embedded server cassandra. */
+    private static EmbeddedCassandraService cassandra;
+    
+    /**
+     * Start cassandra server.
+     * @throws ConfigurationException 
+     *
+     * @throws Exception the exception
+     */
+    protected void startCassandraServer() throws IOException, ConfigurationException
+    {
+        if (!checkIfServerRunning())
+        {
+            System.setProperty("cassandra.config", "cassandra.yaml");
+            loadData();
+            cassandra = new EmbeddedCassandraService();
+            cassandra.start();
+        }
+    }
+
+    
+    /**
+     * Load yaml tables.
+     *
+     * @throws ConfigurationException the configuration exception
+     */
+    private void loadData() throws ConfigurationException
+    {
+        for (KSMetaData table : DatabaseDescriptor.readTablesFromYaml())
+        {
+            for (CFMetaData cfm : table.cfMetaData().values())
+            {
+                CFMetaData.map(cfm);
+            }
+            DatabaseDescriptor.setTableDefinition(table, DatabaseDescriptor.getDefsVersion());
+        }
+    }
+    /**
+     * Check if server running.
+     *
+     * @return true, if successful
+     */
+    private boolean checkIfServerRunning()
+    {
+        try
+        {
+            Socket socket = new Socket("127.0.0.1", 9170);
+            return socket.getInetAddress() != null;
+        } 
+        catch (UnknownHostException e)
+        {
+            return false;
+        }
+        catch (IOException e)
+        {
+            return false;
+        }
+    }
+}
\ No newline at end of file

Added: cassandra/trunk/drivers/java/test/JdbcDriverTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/drivers/java/test/JdbcDriverTest.java?rev=1069593&view=auto
==============================================================================
--- cassandra/trunk/drivers/java/test/JdbcDriverTest.java (added)
+++ cassandra/trunk/drivers/java/test/JdbcDriverTest.java Thu Feb 10 22:34:05 2011
@@ -0,0 +1,270 @@
+/*
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ */
+
+import java.io.IOException;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import org.apache.cassandra.config.ConfigurationException;
+
+/**
+ * Test case for unit test of various methods of JDBC implementation.
+ */
+public class JdbcDriverTest extends BaseTest
+{
+    private java.sql.Connection con = null;
+
+    /**
+     * SetUp
+     */
+    @Override
+    protected void setUp()
+    {
+        try
+        {
+            startCassandraServer();
+            Class.forName("org.apache.cassandra.cql.driver.jdbc.CassandraDriver");
+            con = DriverManager.getConnection("jdbc:cassandra:root/root@localhost:9170/Keyspace1");
+            prepareData();
+        }
+        catch (ClassNotFoundException e)
+        {
+            fail(e.getMessage());
+        }
+        catch(IOException ioex)
+        {
+            fail(ioex.getMessage());
+        }
+        catch (SQLException e)
+        {
+            fail(e.getMessage());
+        } 
+        catch (ConfigurationException e)
+        {
+            fail(e.getMessage());
+        }
+    }
+
+    /**
+     * Method to test statement.
+     */
+    public void testWithStatement()
+    {
+        try
+        {
+            scrollResultset(withStatement(con), "first", "last");
+        }
+        catch (SQLException e)
+        {
+            fail(e.getMessage());
+        }
+    }
+
+   /**
+     * Method to test with prepared statement.
+     */
+    public void testWithPreparedStatement()
+    {
+        try
+        {
+            final String selectQ = "SELECT \"first\", \"last\" FROM Standard1 WHERE KEY=\"jsmith\"";
+            scrollResultset(withPreparedStatement(con, selectQ), "first", "last");
+        }
+        catch (SQLException e)
+        {
+            fail(e.getMessage());
+        }
+        tearDown();
+    }
+
+    /**
+     * Method to test with update statement.
+     */
+    public void testWithUpdateStatement()
+    {
+        try
+        {
+            final String updateQ = "UPDATE Standard1 SET \"firstN\" = \"jdbc\", \"lastN\"
= \"m\" WHERE KEY = \"jsmith\"";
+            withUpdateStatement(con, updateQ);
+            final String updateSelect = "SELECT \"firstN\", \"lastN\" FROM Standard1 WHERE
KEY=\"jsmith\"";
+            scrollResultset(withPreparedStatement(con, updateSelect), "firstN", "lastN");
+        }
+        catch (SQLException e)
+        {
+            fail(e.getMessage());
+        }
+    }
+
+    /**
+     * Method to test with Delete statement.
+     */
+    public void testWithDeleteStatement()
+    {
+        try
+        {
+            // Delete
+            final String deleteQ = "DELETE \"firstN\", \"lastN\" FROM Standard1 WHERE KEY=\"jsmith\"";
+            withDeleteStatement(con, deleteQ);
+            String updateSelect = "SELECT \"firstN\", \"lastN\" FROM Standard1 WHERE KEY=\"jsmith\"";
+            scrollResultset(withPreparedStatement(con, updateSelect), "firstN", "lastN");
+        } 
+        catch (SQLException e)
+        {
+            fail(e.getMessage());
+        }
+    }
+
+    @Override
+    protected void tearDown()
+    {
+        try
+        {
+            if (con != null)
+            {
+                deleteData();
+                con.close();
+                con = null;
+            }
+        } 
+        catch (SQLException e)
+        {
+            fail(e.getMessage());
+        }
+    }
+
+    /**
+     * Method to prepare data.
+     * 
+     * @throws SQLException
+     *             sql exception.
+     */
+    private void prepareData() throws SQLException
+    {
+        final String updateQ = "UPDATE Standard1 SET \"first\" = \"firstrec\", \"last\" =
\"lastrec\" WHERE KEY = \"jsmith\"";
+        withUpdateStatement(con, updateQ);
+    }
+
+    /**
+     * Method to delete data.
+     * 
+     * @throws SQLException
+     *             sql exception.
+     */
+    private void deleteData() throws SQLException
+    {
+        final String updateQ = "TRUNCATE Standard1";
+        withUpdateStatement(con, updateQ);
+    }
+
+    /**
+     * With statement method.
+     * 
+     * @param con
+     *            connection object.
+     * @return rSet result set.
+     * @throws SQLException
+     *             sql exception.
+     */
+    private static ResultSet withStatement(final Connection con) throws SQLException
+    {
+        String selectQ = "SELECT \"first\", \"last\" FROM Standard1 WHERE KEY=\"jsmith\"";
+        Statement stmt = con.createStatement();
+        return stmt.executeQuery(selectQ);
+    }
+
+    /**
+     * With prepared statement method.
+     * 
+     * @param con
+     *            connection object.
+     * @return rSet result set.
+     * @throws SQLException
+     *             sql exception.
+     */
+    private static ResultSet withPreparedStatement(final Connection con, final String selectQ)
throws SQLException
+    {
+        PreparedStatement statement = con.prepareStatement(selectQ);
+        return statement.executeQuery();
+    }
+
+    /**
+     * With scroll result set.
+     * 
+     * @param rSet
+     *            result set.
+     * @param columnName
+     *            column names.
+     * @throws SQLException
+     *             sql exception.
+     */
+    private static void scrollResultset(final ResultSet rSet, final String... columnNames)
throws SQLException
+    {
+        assertNotNull(rSet);
+        while (rSet.next())
+        {
+            assertNotNull(rSet.getString(0));
+            assertNotNull(rSet.getString(columnNames[0]));
+            assertNotNull(rSet.getString(columnNames[1]));
+        }
+    }
+
+    /**
+     * With update statement
+     * 
+     * @param con
+     *            connection object.
+     * @param updateQ
+     *            update query.
+     * @throws SQLException
+     *             sql exception.
+     */
+    private static void withUpdateStatement(final Connection con, final String updateQ) throws
SQLException
+    {
+        PreparedStatement statement = con.prepareStatement(updateQ);
+        statement.execute();
+    }
+
+    /**
+     * With Delete statement
+     * 
+     * @param con
+     *            connection object.
+     * @param deleteQ
+     *            delete query.
+     * @throws SQLException
+     *             sql exception.
+     */
+    private static void withDeleteStatement(final Connection con, final String deleteQ) throws
SQLException
+    {
+        PreparedStatement statement = con.prepareStatement(deleteQ);
+        statement.execute();
+    }
+    /*
+     * private static void withCreateStatement(Connection con) throws
+     * SQLException { String createQ =
+     * "CREATE TABLE JdbcU(\"firstN\", \"lastN\") "; PreparedStatement statement
+     * = con.prepareStatement(createQ); statement.execute(); }
+     */
+}



Mime
View raw message