Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show schemas doesn't work #2

Open
damasofc opened this issue Jul 31, 2018 · 1 comment
Open

show schemas doesn't work #2

damasofc opened this issue Jul 31, 2018 · 1 comment

Comments

@damasofc
Copy link

I was trying to get all the schemas that I have in my H2 DB in I get this error:
Error: Error running instance method org.h2.jdbc.JdbcSQLException: Method is not allowed for a query. Use execute or executeQuery instead of executeUpdate; SQL statement: show schemas [90001-197]

I've noticed that the error is in the function execute in the line 421 of the index.js of H2
the problem occurs because you have an If asking if the query doesn't starts with select your run this code:
executeQuery = statement.executeUpdate;

but in this case my query doesn't starts with select but is not a sql statements that insert/update/delete, so that cause the error.

again thank you very much for this adapter,

@kbarbounakis
Copy link
Collaborator

This trick (which validates a SELECT expression) is running because native adapter separates the execution of SELECT or INSERT, UPDATE, DELETE statements (as you described above).
So, I think is better to use raw connection for this statement only ("SHOW SCHEMAS").
e.g.

//open connection
context.db.open(function(err) {
   if (err) {
     return callback(err);
  }
  //use rawConnection (jdbc connection)
  context.db.rawConnection.conn.createStatement(function(err, statement) {
                        if (err) { return callback(err); }
                        statement.executeQuery("SHOW SCHEMAS", function(err, result) {
 return callback(err, result);
           });
      });
});

I added an issue to include "show schemas" statement in valid SELECT expressions for H2 Adapters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants