Issue Details (XML | Word | Printable)

Key: JDBC-541
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Mark Rotteveel
Reporter: Diego Scarmal
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Jaybird JCA/JDBC Driver

Allow to define default charset when creating a database with org.firebirdsql.management.FBManager

Created: 07/Aug/18 02:03 PM   Updated: 25/May/19 10:03 AM
Component/s: None
Affects Version/s: None
Fix Version/s: Jaybird 3.0.6, Jaybird 4


 Description  « Hide
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.


 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Mark Rotteveel added a comment - 07/Aug/18 03:14 PM
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.


Mark Rotteveel added a comment - 06/Apr/19 08:19 AM
Backported to Jaybird 3.0.6