Subject | trailing spaces with UNICODE_FSS |
---|---|
Author | Dmitry Shohov |
Post date | 2004-02-23T23:09:41Z |
Hi!
I created database with default character set UNICODE_FSS. When I
try to get values from columns with char type, JayBird returns strings
with trailing spaces (e.g. if there is column with type char(1) and
value 'A' it returns 'A ' with two spaces at the end).
Is this a bug? Or may be I missed something?
I used JayBird 1.5 beta3 and firebird 1.5.0/1.0.3. OS - Win2000.
Thanks,
Dmitry Shohov
Database script:
CREATE DATABASE 'C:\Projects\bugtest\bugtest.gdb'
USER 'SYSDBA' PASSWORD 'masterkey'
DEFAULT CHARACTER SET UNICODE_FSS;
CREATE TABLE TESTTABLE (
TESTVALUE CHAR(1)
);
INSERT INTO TESTTABLE VALUES('A');
COMMIT;
Java test class:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
public class Test {
public static void main(String[] args) {
try {
Class.forName("org.firebirdsql.jdbc.FBDriver");
Connection connection = DriverManager.getConnection("jdbc:firebirdsql:localhost/3050:c:\\Projects\\bugtest\\bugtest.gdb?lc_ctype=UNICODE_FSS", "sysdba", "masterkey");
try {
PreparedStatement preparedStatement = connection.prepareStatement("SELECT testvalue FROM testtable");
ResultSet resultSet = preparedStatement.executeQuery();
if (resultSet.next()) {
String value = resultSet.getString(1);
if (value.equals("A")) {
System.out.println("Correct value");
} else if (value.equals("A ")) {
System.out.println("Value with trailing spaces");
} else {
System.out.println("Value: '" + value + "'");
}
System.out.println("Column size: " + resultSet.getMetaData().getColumnDisplaySize(1));
} else {
System.out.println("Empty ResultSet");
}
} finally {
connection.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
I created database with default character set UNICODE_FSS. When I
try to get values from columns with char type, JayBird returns strings
with trailing spaces (e.g. if there is column with type char(1) and
value 'A' it returns 'A ' with two spaces at the end).
Is this a bug? Or may be I missed something?
I used JayBird 1.5 beta3 and firebird 1.5.0/1.0.3. OS - Win2000.
Thanks,
Dmitry Shohov
Database script:
CREATE DATABASE 'C:\Projects\bugtest\bugtest.gdb'
USER 'SYSDBA' PASSWORD 'masterkey'
DEFAULT CHARACTER SET UNICODE_FSS;
CREATE TABLE TESTTABLE (
TESTVALUE CHAR(1)
);
INSERT INTO TESTTABLE VALUES('A');
COMMIT;
Java test class:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
public class Test {
public static void main(String[] args) {
try {
Class.forName("org.firebirdsql.jdbc.FBDriver");
Connection connection = DriverManager.getConnection("jdbc:firebirdsql:localhost/3050:c:\\Projects\\bugtest\\bugtest.gdb?lc_ctype=UNICODE_FSS", "sysdba", "masterkey");
try {
PreparedStatement preparedStatement = connection.prepareStatement("SELECT testvalue FROM testtable");
ResultSet resultSet = preparedStatement.executeQuery();
if (resultSet.next()) {
String value = resultSet.getString(1);
if (value.equals("A")) {
System.out.println("Correct value");
} else if (value.equals("A ")) {
System.out.println("Value with trailing spaces");
} else {
System.out.println("Value: '" + value + "'");
}
System.out.println("Column size: " + resultSet.getMetaData().getColumnDisplaySize(1));
} else {
System.out.println("Empty ResultSet");
}
} finally {
connection.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}