2

I am trying to create a temporary table inside of AWS redshift using the java SDK.

 // Redshift JDBC 4.1 driver: com.amazon.redshift.jdbc41.Driver
 String command = "CREATE TABLE test (FirstName varchar(255));"
 Class.forName("com.amazon.redshift.jdbc41.Driver");
 conn = DriverManager.getConnection(dbURL, props);
 stmt = conn.createStatement();
 ResultSet rs = stmt.executeQuery(command);

When running this code the table is created successfully but on the return, an error is thrown

com.amazon.dsi.dataengine.impl.DSISimpleRowCountResult cannot be cast to com.amazon.dsi.dataengine.interfaces.IResultSet

Everything will work if I use a command that returns something, such as

"Select * FROM test;" 
"SELECT * FROM test LIMIT 0;"

I didn't see any documentation for this problem in the AWS READMEs or other stack overflow questions for this problem. It seems to me that there is a special class in the driver for when nothing is returned from the statement that is not able to be cast to the ResultSet class.

The redshift driver version is 1.1.13.1013 .

Any help would be greatly appreciated!

1 Answer 1

2

I had the same problem. You can solve this easily. Instead of

stmt.executeQuery(command);

please try

stmt.execute(command);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.