Vertica throwing exception for : Multiple SQL Statement Support
I am using Java Vertica jdbc client 7.1.2. When I execute any multi-statement query it fails with exception :
java.sql.SQLDataException: [Vertica]JDBC Exactly one result expected, but 2 results created from query "". Query not executed.
I ran the same query mentioned here.
I tried adding 'allowMultiQueries=true' in jdbc URL, but it didn't work.
Code :
String url = "jdbc:vertica://myIP:5433/db?allowMultiQueries=true";
String sql = "CREATE TABLE t(a INT);INSERT INTO t VALUES(10);";
Properties myProp = new Properties();
myProp.put("user", "user");
myProp.put("password", "pass");
Connection dbConnection = DriverManager.getConnection(url,myProp);
Statement statement = dbConnection.createStatement();
statement.executeUpdate(sql);
Any help would be appreciated.
Answers
Note what the doc says:
"Only the Statement interface supports executing strings containing multiple SQL statements. You cannot use multiple statement strings with PreparedStatement."
Fyi...
Multiple Active Result Sets (MARS) Support was added in Vertica 7.2.0.
See:
https://my.vertica.com/docs/7.2.x/HTML/index.htm#Authoring/NewFeatures/7.2/7.2.0/MultipleActiveResultSets.htm?TocPath=Vertica 7.2.x New Features|New%20Features%20and%20Changes%20in%20Vertica%207.2.0|Client%20Connectivity|_____2