JDBC ODBC and 4D Database : when reading a row, the first space character of a column is not sent

StackOverflow https://stackoverflow.com/questions/22175961

Domanda

I use a remote 4D v11 database and an ODBC 4D Driver on Windows to access and read the data. The issue is about some rows of a table: these rows have columns beginning with a space character. It's intended.

My java application has to retrieve these columns with their first space character. But it doesn't work.

The ODBC 4D driver works fine. Testing it using Microsoft Query in Excel, reading the table the columns have their first space character.

In my java program, i use the JDBC ODBC Driver (jdk 1.7.0_51). The open(), Statement, execute() and ResultSet instructions or classes are standard JDBC. Unfortunately, the first space character is never retrieved when reading.

The column is seen as CLOB:

int myColumnWithFirstSpace = 5;
ResultSetMetaData rsmd = rs.getMetaData();
String type = rsmd.getColumnTypeName(myColumnWithFirstSpace );
System.out.println(type); // print CLOB

The only class supported is String:

String text= rs.getString(myColumnWithFirstSpace);
// other types return "Operation not yet supported"
System.out.println(text); // print the content of the column

And unfortunately no first space character in the printed text. Where can be the error? Thanks!

È stato utile?

Soluzione

I was able to recreate your issue using the JDBC-ODBC Bridge and the Microsoft SQL Server ODBC driver.

  • When retrieving an nvarchar value with a leading space from both C# and VBA using the SQL Server ODBC driver the leading space is preserved.
  • Retrieving that same value from Java via the SQL Server JDBC driver also preserved the leading space.
  • However, retrieving that value from Java via the JDBC-ODBC Bridge strips the leading space.

So, it looks like the JDBC-ODBC Bridge is not suitable for your particular project and you may need to locate a JDBC driver for 4D. You might want to start your search here.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top