Jaybird / JDBC + National characters in path

2k views Asked by At

I'm working with Firebird database in Java. Everything works fine, but I have problem with connecting to my database if database file path contains national characters, eg. "á" or "č".

Sample exception:

org.firebirdsql.jdbc.FBSQLException: GDS Exception. 335544344. I/O error during "CreateFile (open)" operation for file "Z:/testing/á/sample.fdb"

Path is correct, database exists. Jaybird / JDBC has problem with "á" character in path.

Any ideas how to fix it or where is problem? Thanks for all responses.

OS: Windows 7 Pro 64 bit
JDK: 1.7.0.25
Jaybird: 2.2.3

1

There are 1 answers

1
Mark Rotteveel On BEST ANSWER

Starting with Jaybird 3, database filename will always be sent as UTF-8, if the server is Firebird 2.5 or higher.

Jaybird 2.2 and earlier has limited support for special characters in the databasename. There are several options you can use to workaround this problem, but if they actually work depends highly on the version of Firebird and the default characterset of the OS (where Firebird is running).

Option 1: use connection property filename_charset=<name of charset> where <name of charset> is the default character set of the operating system where the Firebird server is running.

For example:

jdbc:firebirdsql://myserver/mydatabase?filename_charset=Cp1252

Option 2 (Firebird 2.5 or higher, with Jaybird 2.2): use the workaround described in JDBC-251:

Start your Java application with -Dfile.encoding=UTF8 and include utf8_filename=1 in the connection URL:

jdbc:firebirdsql://myserver/mydatabase?utf8_filename=1

When using this option, make sure that you already specify a connection characterset using connection property charSet, localEncoding or local_encoding (for Java character set names), and/or encoding or lc_ctype (for Firebird character set names). If not, you are using Firebird character set NONE which uses the JVM default character set, and you will need to set the charSet to the 'normal' default encoding of your JVM to prevent character set conversion issues because of the changed value of file.encoding (in some cases - in addition to specifying charSet - you may also explicitly need to set encoding to NONE).

Option 3: Define an alias with only ASCII characters in aliases.conf of the firebird server for the database and connect using this alias instead:

jdbc:firebirdsql://myserver/thealias

Disclosure: I am one of the Jaybird developers