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

Allow to define default charset when creating a database with org.firebirdsql.management.FBManager [JDBC541] #574

Closed
firebird-issue-importer opened this issue Aug 7, 2018 · 8 comments

Comments

@firebird-issue-importer
Copy link

@firebird-issue-importer firebird-issue-importer commented Aug 7, 2018

Submitted by: Diego Scarmal (pebabr)

It is not possible to choose a default charset (defaults to NONE) when creating a database with the FBManager.

I propose a setter on it to define the default charset, something like the following

FBManager fbm = new FBManager();
fbm.setDefaultCharset("UTF8");
...

Quoting the workaroung provided by Mark Rotteveel stack overflow (https://stackoverflow.com/questions/51715228/set-default-charset-on-a-database-created-with-fbmanager/51726114#51726114.

As a workaround you will need to alter the default character set after creating the database.

For Firebird 3 and higher you can do this by using

ALTER DATABASE SET DEFAULT CHARACTER SET UTF8

See also Alter the Default Character Set in the Firebird 3 release notes.

For Firebird 2.5 and earlier you'll need to modify the system tables directly (this is no longer supported in Firebird 3):

UPDATE RDB$DATABASE SET RDB$CHARACTER_SET_NAME = 'UTF8'

Replace UTF8 with your intended default character set if it is a different character set.

Either statement must be executed as the database owner or as user SYSDBA.

Be aware, changing the default character set only has effect on columns created after the new default has been set. Existing (var)char columns will retain their old character set.

Commits: 449ba79 5a8b1e7

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Aug 7, 2018

Modified by: Diego Scarmal (pebabr)

description: It is not possible to choose a default charset (defaults to NONE) when creating a database with the FBManager.

I propose a setter on it to define the default charset, something like the following
{{
FBManager fbm = new FBManager();
fbm.setDefaultCharset("UTF8");
...
}}

Quoting the workaroung provided by Mark Rotteveel @ [stack overflow|https://stackoverflow\.com/questions/51715228/set\-default\-charset\-on\-a\-database\-created\-with\-fbmanager/51726114#⁠51726114\]

{quote}
As a workaround you will need to alter the default character set after creating the database.

For Firebird 3 and higher you can do this by using

ALTER DATABASE SET DEFAULT CHARACTER SET UTF8

See also Alter the Default Character Set in the Firebird 3 release notes.

For Firebird 2.5 and earlier you'll need to modify the system tables directly (this is no longer supported in Firebird 3):

UPDATE RDB$DATABASE SET RDB$CHARACTER_SET_NAME = 'UTF8'

Replace UTF8 with your intended default character set if it is a different character set.

Either statement must be executed as the database owner or as user SYSDBA.

Be aware, changing the default character set only has effect on columns created after the new default has been set. Existing (var)char columns will retain their old character set.
{quote}

=>

It is not possible to choose a default charset (defaults to NONE) when creating a database with the FBManager.

I propose a setter on it to define the default charset, something like the following

FBManager fbm = new FBManager();
fbm.setDefaultCharset("UTF8");
...

Quoting the workaroung provided by Mark Rotteveel stack overflow (https://stackoverflow.com/questions/51715228/set-default-charset-on-a-database-created-with-fbmanager/51726114#51726114.

As a workaround you will need to alter the default character set after creating the database.

For Firebird 3 and higher you can do this by using

ALTER DATABASE SET DEFAULT CHARACTER SET UTF8

See also Alter the Default Character Set in the Firebird 3 release notes.

For Firebird 2.5 and earlier you'll need to modify the system tables directly (this is no longer supported in Firebird 3):

UPDATE RDB$DATABASE SET RDB$CHARACTER_SET_NAME = 'UTF8'

Replace UTF8 with your intended default character set if it is a different character set.

Either statement must be executed as the database owner or as user SYSDBA.

Be aware, changing the default character set only has effect on columns created after the new default has been set. Existing (var)char columns will retain their old character set.

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Aug 7, 2018

Commented by: @mrotteveel

Tentatively scheduled for Jaybird 4, may slip to a later version. I'm not 100% sure if the Firebird API used for creating the database exposes an option to set the default character set; this may need explicit execution of a statement after creation of the database.

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Aug 7, 2018

Modified by: @mrotteveel

Fix Version: Jaybird 4 [ 10441 ]

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Dec 29, 2018

Commented by: @mrotteveel

5a8b1e7

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Dec 29, 2018

Modified by: @mrotteveel

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Apr 6, 2019

Commented by: @mrotteveel

Backported to Jaybird 3.0.6

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Apr 6, 2019

Modified by: @mrotteveel

Fix Version: Jaybird 3.0.6 [ 10883 ]

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented May 25, 2019

Modified by: @mrotteveel

status: Resolved [ 5 ] => Closed [ 6 ]

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

Successfully merging a pull request may close this issue.

None yet
2 participants