Re: JDBC - Can't get unicode with ResultSet.getString()
- From: "David Thielen" <thielen@xxxxxxxxxxxxx>
- Date: Tue, 6 Sep 2005 05:12:01 -0700
Hello;
The column is a nvarchar and I use ResultSet.getString() to retrieve it.
For most of my access I use hibernate and it does successfully store and
return the unicode values for the string (that is how the values originally
get written to the database).
But when I get a connection dorectly and call getString(), then I get just
ascii and ? for the chars > 127.
Is there something special I have to do when I get the connection or a call
other than getString I should use? I tried getBytes but that threw an
exception.
--
thanks - dave
"Matt Neerincx [MSFT]" wrote:
> You can try microsoft.public.sqlserver.jdbcdriver this area is good.
>
> But I can help you here in the meanwhile.
>
> What is the collation set on the database as well as the columns on the
> table? This can have an impact, I could set this up and reproduce the
> problem, etc...
>
> --
> Matt Neerincx [MSFT]
>
> This posting is provided "AS IS", with no warranties, and confers no rights.
>
> Please do not send email directly to this alias. This alias is for newsgroup
> purposes only.
>
> "David Thielen" <thielen@xxxxxxxxxxxxx> wrote in message
> news:9A43688E-224B-4617-B136-531EB8011D1E@xxxxxxxxxxxxxxxx
> > The data is correct in Sql Server - I viewed it there.
> >
> > And it is the jdbc getString() that returns it wrong, I viewed that in my
> > debugger.
> >
> > So for somereason the Microsoft Sql Server JDBC driver is not returning
> > unicode. Is there a special setting needed to do this? Or should I use a
> > call
> > other than getString()?
> >
> > --
> > thanks - dave
> >
> >
> > "Steven Cheng[MSFT]" wrote:
> >
> >> Hi Dave,
> >>
> >> Welcome to MSDN newsgroup.
> >> Regarding on the problem you mentioned, here are some of my understanding
> >> and suggestions:
> >>
> >> Since you mentioned that the SQLServer field is a nvarchar column, so I
> >> think the sqldatabase should have stored the data correctly as long as
> >> there hasn't occur converting issue when you put them into the sql db.
> >>
> >> I think you can verfify this by using the SQLserver's query analyzer or
> >> other client component such as .NET, VB to query the certain column to
> >> see
> >> whether the data stored in SQLdb is ok. If the data is ok, we should
> >> have
> >> a further look in the data retrieving and displaying portion. For
> >> example,
> >> it's possbile that the data is retrieved incorrectly when you through
> >> JDBC
> >> api or being converted incorrectly when write out to the client page(when
> >> developing web application). BTW, are you using THE JDBC in JSP web
> >> application? If so, there is likely problems in charset as I mentioned
> >> above.
> >>
> >> Thanks,
> >>
> >>
> >> Steven Cheng
> >> Microsoft Online Support
> >>
> >> Get Secure! www.microsoft.com/security
> >> (This posting is provided "AS IS", with no warranties, and confers no
> >> rights.)
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >> --------------------
> >> | Thread-Topic: JDBC - Can't get unicode with ResultSet.getString()
> >> | thread-index: AcWv9h2buHCTzq/1TX+a9rFn97MqDA==
> >> | X-WBNR-Posting-Host: 199.45.247.98
> >> | From: "=?Utf-8?B?RGF2aWQgVGhpZWxlbg==?=" <thielen@xxxxxxxxxxxxx>
> >> | Subject: JDBC - Can't get unicode with ResultSet.getString()
> >> | Date: Fri, 2 Sep 2005 12:40:04 -0700
> >> | Lines: 18
> >> | Message-ID: <DEBAF362-6134-43F1-99FE-80C4B2AC1732@xxxxxxxxxxxxx>
> >> | MIME-Version: 1.0
> >> | Content-Type: text/plain;
> >> | charset="Utf-8"
> >> | Content-Transfer-Encoding: 8bit
> >> | X-Newsreader: Microsoft CDO for Windows 2000
> >> | Content-Class: urn:content-classes:message
> >> | Importance: normal
> >> | Priority: normal
> >> | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
> >> | Newsgroups: microsoft.public.sqlserver.odbc
> >> | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
> >> | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
> >> | Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.sqlserver.odbc:2658
> >> | X-Tomcat-NG: microsoft.public.sqlserver.odbc
> >> |
> >> | Hi;
> >> |
> >> | I am using MS Sql Server and it has an nvarchar field holding a name.
> >> |
> >> | For ascii chars I get back the text in the database.
> >> |
> >> | But if it is anything other than ascii, I get back a ? for each non
> >> 7-bit
> >> | character. So a field with "a風bбc" returns "a?b?c"
> >> |
> >> | What do I need to set/do to get back the unicode values in the
> >> database?
> >> |
> >> | --
> >> | thanks - dave
> >> |
> >> | Note: I couldn't find a forum for the Sql Server jdbc driver so I
> >> figured
> >> | this was the closest thing.
> >> |
> >> |
> >> |
> >>
> >>
>
>
>
.
- References:
- JDBC - Can't get unicode with ResultSet.getString()
- From: David Thielen
- RE: JDBC - Can't get unicode with ResultSet.getString()
- From: Steven Cheng[MSFT]
- RE: JDBC - Can't get unicode with ResultSet.getString()
- From: David Thielen
- Re: JDBC - Can't get unicode with ResultSet.getString()
- From: Matt Neerincx [MSFT]
- JDBC - Can't get unicode with ResultSet.getString()
- Prev by Date: Re: JDBC - Can't get unicode with ResultSet.getString()
- Next by Date: RE: JDBC - Can't get unicode with ResultSet.getString()
- Previous by thread: Re: JDBC - Can't get unicode with ResultSet.getString()
- Next by thread: RE: JDBC - Can't get unicode with ResultSet.getString()
- Index(es):
Relevant Pages
|