Return-Path: X-Original-To: apmail-cassandra-commits-archive@www.apache.org Delivered-To: apmail-cassandra-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3F4EE77EC for ; Thu, 18 Aug 2011 01:33:55 +0000 (UTC) Received: (qmail 26222 invoked by uid 500); 18 Aug 2011 01:33:55 -0000 Delivered-To: apmail-cassandra-commits-archive@cassandra.apache.org Received: (qmail 26177 invoked by uid 500); 18 Aug 2011 01:33:54 -0000 Mailing-List: contact commits-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cassandra.apache.org Delivered-To: mailing list commits@cassandra.apache.org Received: (qmail 26168 invoked by uid 99); 18 Aug 2011 01:33:54 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 18 Aug 2011 01:33:54 +0000 X-ASF-Spam-Status: No, hits=-2001.1 required=5.0 tests=ALL_TRUSTED,RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 18 Aug 2011 01:33:51 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 71641C10A8 for ; Thu, 18 Aug 2011 01:33:29 +0000 (UTC) Date: Thu, 18 Aug 2011 01:33:29 +0000 (UTC) From: "Cathy Daw (JIRA)" To: commits@cassandra.apache.org Message-ID: <1433846415.47532.1313631209461.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Created] (CASSANDRA-3052) CQL: ResultSet.next() gives NPE when run after an INSERT or CREATE statement MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org CQL: ResultSet.next() gives NPE when run after an INSERT or CREATE statement ---------------------------------------------------------------------------- Key: CASSANDRA-3052 URL: https://issues.apache.org/jira/browse/CASSANDRA-3052 Project: Cassandra Issue Type: Bug Reporter: Cathy Daw This test script used to work until I upgraded the jdbc driver to 1.0.4. *CQL 1.0.4*: apache-cassandra-cql-1.0.4-SNAPSHOT.jar build at revision 1158979 *Repro Script*: * drop in test directory, change package declaration and run: ant test -Dtest.name=resultSetNPE * The script gives you a NullPointerException when you uncomment out the following lines after a CREATE or INSERT statement. {code} colCount = res.getMetaData().getColumnCount(); res.next(); {code} * Please note that there is no need to comment out those lines if a SELECT statement was run prior. {code} package com.datastax.bugs; import java.sql.DriverManager; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import org.junit.Test; public class resultSetNPE { @Test public void createKS() throws Exception { Connection initConn = null; Connection connection = null; ResultSet res; Statement stmt; int colCount = 0; Class.forName("org.apache.cassandra.cql.jdbc.CassandraDriver"); // Check create keyspace initConn = DriverManager.getConnection("jdbc:cassandra://127.0.0.1:9160/default"); stmt = initConn.createStatement(); try { System.out.println("Running DROP KS Statement"); res = stmt.executeQuery("DROP KEYSPACE ks1"); // res.next(); } catch (SQLException e) { if (e.getMessage().startsWith("Keyspace does not exist")) { // Do nothing - this just means you tried to drop something that was not there. // res = stmt.executeQuery("CREATE KEYSPACE ks1 with strategy_class = 'org.apache.cassandra.locator.SimpleStrategy' and strategy_options:replication_factor=1"); } } System.out.println("Running CREATE KS Statement"); res = stmt.executeQuery("CREATE KEYSPACE ks1 with strategy_class = 'org.apache.cassandra.locator.SimpleStrategy' and strategy_options:replication_factor=1"); // res.next(); initConn.close(); } @Test public void createCF() throws Exception { Class.forName("org.apache.cassandra.cql.jdbc.CassandraDriver"); int colCount = 0; Connection connection = DriverManager.getConnection("jdbc:cassandra://127.0.0.1:9160/ks1"); Statement stmt = connection.createStatement(); System.out.print("Running CREATE CF Statement"); ResultSet res = stmt.executeQuery("CREATE COLUMNFAMILY users (KEY varchar PRIMARY KEY, password varchar, gender varchar, session_token varchar, state varchar, birth_year bigint)"); //colCount = res.getMetaData().getColumnCount(); System.out.println(" -- Column Count: " + colCount); //res.next(); connection.close(); } @Test public void simpleSelect() throws Exception { Class.forName("org.apache.cassandra.cql.jdbc.CassandraDriver"); int colCount = 0; Connection connection = DriverManager.getConnection("jdbc:cassandra://127.0.0.1:9160/ks1"); Statement stmt = connection.createStatement(); System.out.print("Running INSERT Statement"); ResultSet res = stmt.executeQuery("INSERT INTO users (KEY, password) VALUES ('user1', 'ch@nge')"); //colCount = res.getMetaData().getColumnCount(); System.out.println(" -- Column Count: " + colCount); //res.next(); System.out.print("Running SELECT Statement"); res = stmt.executeQuery("SELECT KEY, gender, state FROM users"); colCount = res.getMetaData().getColumnCount(); System.out.println(" -- Column Count: " + colCount); res.getRow(); res.next(); connection.close(); } } {code} -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira