How does ResultSet.getString() work?

How does ResultSet.getString() work?

Post by Daihar » Sun, 13 Jul 2003 03:16:32



Hi.

I am trying to resolve a problem using JDBC and our ODBC-compliant database
engine.  We use the compiler-defined wchar_t to store Unicode data in our
database.  Now, using ResultSet.getString(), I cannot retrieve the Unicode
data from our database.  Does getString() expect the underlying data to be
an ASCII string?

As a workaround, I use ResultSet.getCharacterStream().readline().getBytes()
to retrieve the java.io.BufferedReader object and convert it to a Java
String.

If anyone can shed light on this, I would much appreciate it.

Thanks,
Dai

 
 
 

How does ResultSet.getString() work?

Post by Lothar Kimmeringe » Sun, 13 Jul 2003 08:10:02



> I am trying to resolve a problem using JDBC and our ODBC-compliant database
> engine.  We use the compiler-defined wchar_t to store Unicode data in our
> database.  Now, using ResultSet.getString(), I cannot retrieve the Unicode
> data from our database.  Does getString() expect the underlying data to be
> an ASCII string?

If you're connecting the database using the jdbc-odbc-bridge
provided with Java, you need to know that this is a very old
one and you should try to find a JDBC-driver for your specific
database. Which one are you using?

Quote:> As a workaround, I use ResultSet.getCharacterStream().readline().getBytes()
> to retrieve the java.io.BufferedReader object and convert it to a Java
> String.

Sounds like you're using a JDBC-driver anyway (or does the
bridge support character-streams?). Again, what database
are you using and is wchar_t a known datatype of the database,
so that the driver is able to cope with that correctly to
create the right String-contents? If not, you will need to read
it the way you're already doing it.

How getString is implemented is dependent of the JDBC-driver.

Regards, Lothar
--

               PGP-encrypted mails preferred (Key-ID: 0x8BC3CD81)

Always remember: The answer is forty-two, there can only be wrong
                 questions!

 
 
 

How does ResultSet.getString() work?

Post by Daihar » Wed, 16 Jul 2003 00:52:18




> > As a workaround, I use

ResultSet.getCharacterStream().readline().getBytes()

Quote:> > to retrieve the java.io.BufferedReader object and convert it to a Java
> > String.

> Sounds like you're using a JDBC-driver anyway (or does the
> bridge support character-streams?). Again, what database
> are you using and is wchar_t a known datatype of the database,
> so that the driver is able to cope with that correctly to
> create the right String-contents? If not, you will need to read
> it the way you're already doing it.

> How getString is implemented is dependent of the JDBC-driver.

Thanks for enlightening me.  That was exactly the problem.  The database we
use is our own product, and we do provide our own JDBC driver for it.  The
way we implemented RecordSet.getString() was returning the string in an
incorrect format when the data type was SQL_WCHAR / SQL_WVARCHAR.  I fixed
the code and recompiled the driver.  Now everything works fine.

Thanks again,
Dai

 
 
 

1. Error doing ResultSet.getString(int) with JDBC/ODBC bridge

I get the following error when ever I do a getString(int) or
getString(String)

SQLException : [Microsoft][ODBC Driver Manager] Invalid cursor state

I can get the ResultSet MetaData and list all of the column names so I
know that I have a good connection.  I am doing a SELECT * FROM table.
I have tried with a WHERE and a know good value.  I put a breakpoint in
at the Statement.executeQuery() and then  copied and pasted the SQL into
MS Query Builder and it ran OK using the same ODBC driver.
Anybody seen this before?

2. ADO program times out when run from trigger

3. Weird getString behaviour for the ResultSet

4. How to fulfil the automatic loading data using Hyperion Essbase OLAP Server database.

5. ResultSet.getString() method

6. Access 97: That darned Error message!

7. ResultSet.getString does percent substitutions

8. Export a foxpro database to a delimited, fix length file.

9. Resultset.getString() with Chinese characters

10. Oracle-WebLogic : Resultset.getString() with data instead of null

11. ResultSet.getBytes() instead of .getString()?

12. Using ResultSet.getString() with different than default encoding