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

Support executing CREATE DATABASE statements [JDBC598] #629

Open
firebird-automations opened this issue Nov 15, 2019 · 6 comments
Open

Support executing CREATE DATABASE statements [JDBC598] #629

firebird-automations opened this issue Nov 15, 2019 · 6 comments

Comments

@firebird-automations
Copy link

Submitted by: @mrotteveel

In all existing versions of Jaybird it is not possible to execute CREATE DATABASE using a JDBC statement. This will yield a "java.sql.SQLSyntaxErrorException: Dynamic SQL Error; SQL error code = -530; Cannot prepare a CREATE DATABASE/SCHEMA statement [SQLState:42000, ISC error code:335544597]". However dropping to the low-level API to try and use executeImmediate will simply do nothing. And connecting but not attach allows to create a database using a native connection, but not using a pure-java connection.

We need to investigate whether it is possible to execute CREATE DATABASE when attached to a database, and if so: how.

See also #27

@firebird-automations
Copy link
Author

Modified by: @mrotteveel

description: In all existing versions of Jaybird it is not possible to execute CREATE DATABASE using a JDBC statement. This will yield a "java.sql.SQLSyntaxErrorException: Dynamic SQL Error; SQL error code = -530; Cannot prepare a CREATE DATABASE/SCHEMA statement [SQLState:42000, ISC error code:335544597]". However dropping to the low-level API to try and use executeImmediate will simply do nothing. And connecting but not attach allows to create a database using a native connection, but not using a pure-java connection.

We need to investigate whether it is possible to execute CREATE DATABASE when attached to a database, and if so: how.

=>

In all existing versions of Jaybird it is not possible to execute CREATE DATABASE using a JDBC statement. This will yield a "java.sql.SQLSyntaxErrorException: Dynamic SQL Error; SQL error code = -530; Cannot prepare a CREATE DATABASE/SCHEMA statement [SQLState:42000, ISC error code:335544597]". However dropping to the low-level API to try and use executeImmediate will simply do nothing. And connecting but not attach allows to create a database using a native connection, but not using a pure-java connection.

We need to investigate whether it is possible to execute CREATE DATABASE when attached to a database, and if so: how.

See also #27

@mrotteveel
Copy link
Member

The appropriate approach would seem to be to parse the create statement client side, populate the appropriate DPB items (maybe inheriting some from the current connection) and then creating a new connection and using FbDatabase.createDatabase().

@AlexPeshkoff
Copy link
Member

We have IUtil::executeCreateDatabase which does >90% of described actions

@mrotteveel
Copy link
Member

We have IUtil::executeCreateDatabase which does >90% of described actions

Jaybird is - by default - a pure Java driver, so I don't want to call functions from fbclient. It might be helpful for reference though.

@prrvchr
Copy link

prrvchr commented Mar 17, 2024

Perhaps the best way to support database creation would be an option in the connection url as is the case for many JDBC drivers.
In any case, this makes it possible to create a new database when connecting and without code...

@mrotteveel
Copy link
Member

@prrvchr Could you also add your opinion to this thread on firebird-java: https://groups.google.com/g/firebird-java/c/N1PHCM8TnPk ?

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

No branches or pull requests

4 participants