This is a discussion on Asking again - ResultSet.getString() & unicode within the MS SQL ODBC forums, part of the Microsoft SQL Server category; --> Hi; I have put a sample program, output, DB contents, etc. at http://www.windward.net/jdbc_unicode.zip When I call ResultSet.getString() it returns ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi; I have put a sample program, output, DB contents, etc. at http://www.windward.net/jdbc_unicode.zip When I call ResultSet.getString() it returns the ? char for any unicode character that does not map to ASCII 0 - 127. Yet when I access it with hibernate, which appears to do the exact same thing - it works. Any ideas???? thanks - dave |
| |||
| Hi Hi Dave, I've posted my reply in your former thread and will do some further research. Also, as I've also mentioned, if the driver really works correctly when wrappered by the Hibernate library, I'd recommend you try consulting in some JAVA forums or community to see whether any experienced java guys can provide some clues on it. 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: Asking again - ResultSet.getString() & unicode | thread-index: AcWz2ZxTVMUmrSHqSQKn21FG7HfG0Q== | X-WBNR-Posting-Host: 199.45.247.98 | From: "=?Utf-8?B?RGF2aWQgVGhpZWxlbg==?=" <thielen@nospam.nospam> | Subject: Asking again - ResultSet.getString() & unicode | Date: Wed, 7 Sep 2005 11:26:06 -0700 | Lines: 15 | Message-ID: <CEFAD23A-E1BA-479B-9923-511D6FDCE30A@microsoft.com> | MIME-Version: 1.0 | Content-Type: text/plain; | charset="Utf-8" | Content-Transfer-Encoding: 7bit | 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!TK2MSFTNGP08.phx.gbl!TK2MSFT NGXA03.phx.gbl | Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.sqlserver.odbc:2678 | X-Tomcat-NG: microsoft.public.sqlserver.odbc | | Hi; | | I have put a sample program, output, DB contents, etc. at | http://www.windward.net/jdbc_unicode.zip | | When I call ResultSet.getString() it returns the ? char for any unicode | character that does not map to ASCII 0 - 127. | | Yet when I access it with hibernate, which appears to do the exact same | thing - it works. | | Any ideas???? | | thanks - dave | | |
| |||
| Hi; I've posted in a bunch of different forums. The java ones all tell me to not use the MS drivers (java people tend to be anti-Microsoft). And in the microsoft.public.sqlserver.jdbcdriver I've received no answers. So you are my only hope... There is no version info in the manifest files but the 3 jar files are dated 08/05/2003 - 10:23 AM. -- thanks - dave "Steven Cheng[MSFT]" wrote: > Hi > > > Hi Dave, > > I've posted my reply in your former thread and will do some further > research. Also, as I've also mentioned, if the driver really works > correctly when wrappered by the Hibernate library, I'd recommend you try > consulting in some JAVA forums or community to see whether any experienced > java guys can provide some clues on it. > > 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: Asking again - ResultSet.getString() & unicode > | thread-index: AcWz2ZxTVMUmrSHqSQKn21FG7HfG0Q== > | X-WBNR-Posting-Host: 199.45.247.98 > | From: "=?Utf-8?B?RGF2aWQgVGhpZWxlbg==?=" <thielen@nospam.nospam> > | Subject: Asking again - ResultSet.getString() & unicode > | Date: Wed, 7 Sep 2005 11:26:06 -0700 > | Lines: 15 > | Message-ID: <CEFAD23A-E1BA-479B-9923-511D6FDCE30A@microsoft.com> > | MIME-Version: 1.0 > | Content-Type: text/plain; > | charset="Utf-8" > | Content-Transfer-Encoding: 7bit > | 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!TK2MSFTNGP08.phx.gbl!TK2MSFT NGXA03.phx.gbl > | Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.sqlserver.odbc:2678 > | X-Tomcat-NG: microsoft.public.sqlserver.odbc > | > | Hi; > | > | I have put a sample program, output, DB contents, etc. at > | http://www.windward.net/jdbc_unicode.zip > | > | When I call ResultSet.getString() it returns the ? char for any unicode > | character that does not map to ASCII 0 - 127. > | > | Yet when I access it with hibernate, which appears to do the exact same > | thing - it works. > | > | Any ideas???? > | > | thanks - dave > | > | > > |
| |||
| Hi Dave, I just performed some test on my side. I used the SQLSERVER 2000 JDBC driver (install the SP3), and query a certain table which contains Chinese wide char data. However, I didn't get any "???" in the return code. Here is my test code: ======================================= public class DBUtil { private static final String url = "jdbc:microsoft:sqlserver://"; private static final String serverName= "157.60.115.99"; private static final String portNumber = "1433"; private static final String databaseName= "globaldev"; private static final String userName = "javauser"; private static final String password = "javauser"; public DBUtil() { super(); } private static String getConnectionUrl(){ return url+serverName+":"+portNumber+";databaseName="+dat abaseName+";"; } private static java.sql.Connection getConnection(){ java.sql.Connection con = null; try{ Class.forName("com.microsoft.jdbc.sqlserver.SQLSer verDriver"); con = java.sql.DriverManager.getConnection(getConnection Url(),userName,password); if(con!=null) System.out.println("Connection Successful!"); }catch(Exception e){ e.printStackTrace(); System.out.println("Error Trace in getConnection() : " + e.getMessage()); } return con; } public static boolean InsertNewUser (String name, String email) throws Exception{ Connection conn = getConnection(); String sql = "insert g_user values('" + name + "', '" + email + "')"; if(conn == null){ return false; } try{ Statement stat = conn.createStatement(); return stat.execute(sql); }catch(Exception ex){ System.out.println(ex.toString()); return false; }finally{ conn.close(); } } public static String QueryData() throws Exception{ Connection conn = getConnection(); if(conn != null){ try{ Statement stat = conn.createStatement(); ResultSet result = stat.executeQuery("select id, name, email from g_user"); while (result.next()) { String name = result.getString("name"); String email = result.getString("email"); System.out.println("Name: " +name + ", email: " + email ); } result.close(); stat.close(); }catch(Exception ex){ System.out.println(ex.toString()); }finally{ conn.close(); } } return null; } } =============================== I haven't seen any particular things need to modify. Anyway, if you can repro your problem with the code I used, I think you may try attach a sqlserver's mdf file(simplified one) to me so that I can perform some tests through your data on my side. 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: Asking again - ResultSet.getString() & unicode | thread-index: AcW0eSQBgN1tNmqYSf633sHiHEYtYg== | X-WBNR-Posting-Host: 199.45.247.98 | From: "=?Utf-8?B?RGF2aWQgVGhpZWxlbg==?=" <thielen@nospam.nospam> | References: <CEFAD23A-E1BA-479B-9923-511D6FDCE30A@microsoft.com> <7PGnYcEtFHA.1252@TK2MSFTNGXA02.phx.gbl> | Subject: RE: Asking again - ResultSet.getString() & unicode | Date: Thu, 8 Sep 2005 06:28:03 -0700 | Lines: 80 | Message-ID: <B25E4840-9D02-4372-A9FE-0DCD48456968@microsoft.com> | MIME-Version: 1.0 | Content-Type: text/plain; | charset="Utf-8" | Content-Transfer-Encoding: 7bit | 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: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA03.phx.gbl | Xref: TK2MSFTNGXA02.phx.gbl microsoft.public.sqlserver.odbc:44121 | X-Tomcat-NG: microsoft.public.sqlserver.odbc | | Hi; | | I've posted in a bunch of different forums. The java ones all tell me to not | use the MS drivers (java people tend to be anti-Microsoft). And in the | microsoft.public.sqlserver.jdbcdriver I've received no answers. | | So you are my only hope... | | There is no version info in the manifest files but the 3 jar files are dated | 08/05/2003 - 10:23 AM. | | -- | thanks - dave | | | "Steven Cheng[MSFT]" wrote: | | > Hi | > | > | > Hi Dave, | > | > I've posted my reply in your former thread and will do some further | > research. Also, as I've also mentioned, if the driver really works | > correctly when wrappered by the Hibernate library, I'd recommend you try | > consulting in some JAVA forums or community to see whether any experienced | > java guys can provide some clues on it. | > | > 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: Asking again - ResultSet.getString() & unicode | > | thread-index: AcWz2ZxTVMUmrSHqSQKn21FG7HfG0Q== | > | X-WBNR-Posting-Host: 199.45.247.98 | > | From: "=?Utf-8?B?RGF2aWQgVGhpZWxlbg==?=" <thielen@nospam.nospam> | > | Subject: Asking again - ResultSet.getString() & unicode | > | Date: Wed, 7 Sep 2005 11:26:06 -0700 | > | Lines: 15 | > | Message-ID: <CEFAD23A-E1BA-479B-9923-511D6FDCE30A@microsoft.com> | > | MIME-Version: 1.0 | > | Content-Type: text/plain; | > | charset="Utf-8" | > | Content-Transfer-Encoding: 7bit | > | 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!TK2MSFTNGP08.phx.gbl!TK2MSFT NGXA03.phx.gbl | > | Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.sqlserver.odbc:2678 | > | X-Tomcat-NG: microsoft.public.sqlserver.odbc | > | | > | Hi; | > | | > | I have put a sample program, output, DB contents, etc. at | > | http://www.windward.net/jdbc_unicode.zip | > | | > | When I call ResultSet.getString() it returns the ? char for any unicode | > | character that does not map to ASCII 0 - 127. | > | | > | Yet when I access it with hibernate, which appears to do the exact same | > | thing - it works. | > | | > | Any ideas???? | > | | > | thanks - dave | > | | > | | > | > | |
| |||
| I have bad news and bad news. First, I found the problem (because your code did work to read and mine didn't): If I call the following to get a Statement: Statement stmt = conn.createStatement(); Then ResultSet.getString() works fine with unicode strings: But If I use the following: Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSI TIVE, ResultSet.CONCUR_UPDATABLE); Then all chars > 127 are returned as an ? I think this is a (BIG BIG BIG) bug. Second: When I ran the code you sent me, it could read unicode values I inserted via Enterprise Manager. But when I called: InsertNewUser("a\u98a8b\u0436c", "escape"); It inserted "a?b?c". And that was using your program with no changes. When I created the g_user table I created an int and two nvarchar columns. ??? - thanks - dave |
| |||
| Sometimes a picture shows things a lot better so you can find your code with some minor changes I made, and screen shots of the database at http://www.windward.net/jdbc2.zip Note that the first row I inserted by hand - it was not created by your program. -- thanks - dave |
| |||
| Hi Dave, I still think the problem should be environment specific since on my local environment, no matter I use Statement stmt = conn.createStatement(); or Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSI TIVE, ResultSet.CONCUR_UPDATABLE); I can get the unicode string correctly from sqlserver. Also, for inserting, I can directly insert unicode in the following style: "\u98a8"; What's your database's Collation setting? Though from my test , this doesn't change the result, I think you can try set the collation to a codepage which can correctly interpret the wide chars. In addition, in T-SQL, when we inserting unicode string, it's recommended that we add "N" Prefix for each string value, so you can try using the following insert statement to see whether it can insert unicode correctly: public static boolean InsertNewUser (String name, String email) throws Exception{ Connection conn = getConnection(); String sql = "insert g_user values(N'" + name + "', N'" + email + "')"; .................................... } Hope helps. 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: Asking again - ResultSet.getString() & unicode | thread-index: AcW1eMlyyC/Dmw/1QQyoC1z0+TfdCA== | X-WBNR-Posting-Host: 199.45.247.98 | From: "=?Utf-8?B?RGF2aWQgVGhpZWxlbg==?=" <thielen@nospam.nospam> | References: <CEFAD23A-E1BA-479B-9923-511D6FDCE30A@microsoft.com> <7PGnYcEtFHA.1252@TK2MSFTNGXA02.phx.gbl> <B25E4840-9D02-4372-A9FE-0DCD48456968@microsoft.com> <mrGDGPRtFHA.768@TK2MSFTNGXA01.phx.gbl> <10F8AE17-DDB4-41B8-8D74-783D97E9E80F@microsoft.com> | Subject: RE: Asking again - ResultSet.getString() & unicode | Date: Fri, 9 Sep 2005 12:58:03 -0700 | Lines: 10 | Message-ID: <181272BD-5477-4ECC-94C2-EF3D54A0C08F@microsoft.com> | MIME-Version: 1.0 | Content-Type: text/plain; | charset="Utf-8" | Content-Transfer-Encoding: 7bit | 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:2691 | X-Tomcat-NG: microsoft.public.sqlserver.odbc | | Sometimes a picture shows things a lot better so you can find your code with | some minor changes I made, and screen shots of the database at | http://www.windward.net/jdbc2.zip | | Note that the first row I inserted by hand - it was not created by your | program. | | -- | thanks - dave | | |
| |||
| Ok, here's some interesting results: First, please keep in mind that if I use hibernate (www.hibernate.org) I can insert and select with no problems on my system. So I don't think it's a configuration issue but instead some setting needed. If I add the N then it inserts fine. Obviously this doesn't help in the select. If I create a database using BOPOMOFO for the collation, then if I insert without the N, the chinese character inserts correctly, but the russian character does not. The select still fails for both characters. So I think the answer for an insert is to use the N'unicode_string' as that solves that problem. But to select, I still can't get it with conn.createStatement(ResultSet.TYPE_SCROLL_INSENSI TIVE, ResultSet.CONCUR_UPDATABLE) Any further ideas? -- thanks - dave "Steven Cheng[MSFT]" wrote: > Hi Dave, > > I still think the problem should be environment specific since on my local > environment, no matter I use > > Statement stmt = conn.createStatement(); > > or > > Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSI TIVE, > ResultSet.CONCUR_UPDATABLE); > > I can get the unicode string correctly from sqlserver. Also, for inserting, > I can directly insert unicode in the following style: > > "\u98a8"; > > What's your database's Collation setting? Though from my test , this > doesn't change the result, I think you can try set the collation to a > codepage which can correctly interpret the wide chars. In addition, in > T-SQL, when we inserting unicode string, it's recommended that we add "N" > Prefix for each string value, so you can try using the following insert > statement to see whether it can insert unicode correctly: > > public static boolean InsertNewUser (String name, String email) throws > Exception{ > > Connection conn = getConnection(); > > String sql = "insert g_user values(N'" + name + "', N'" + > email + "')"; > > .................................... > > } > > > Hope helps. 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: Asking again - ResultSet.getString() & unicode > | thread-index: AcW1eMlyyC/Dmw/1QQyoC1z0+TfdCA== > | X-WBNR-Posting-Host: 199.45.247.98 > | From: "=?Utf-8?B?RGF2aWQgVGhpZWxlbg==?=" <thielen@nospam.nospam> > | References: <CEFAD23A-E1BA-479B-9923-511D6FDCE30A@microsoft.com> > <7PGnYcEtFHA.1252@TK2MSFTNGXA02.phx.gbl> > <B25E4840-9D02-4372-A9FE-0DCD48456968@microsoft.com> > <mrGDGPRtFHA.768@TK2MSFTNGXA01.phx.gbl> > <10F8AE17-DDB4-41B8-8D74-783D97E9E80F@microsoft.com> > | Subject: RE: Asking again - ResultSet.getString() & unicode > | Date: Fri, 9 Sep 2005 12:58:03 -0700 > | Lines: 10 > | Message-ID: <181272BD-5477-4ECC-94C2-EF3D54A0C08F@microsoft.com> > | MIME-Version: 1.0 > | Content-Type: text/plain; > | charset="Utf-8" > | Content-Transfer-Encoding: 7bit > | 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:2691 > | X-Tomcat-NG: microsoft.public.sqlserver.odbc > | > | Sometimes a picture shows things a lot better so you can find your code > with > | some minor changes I made, and screen shots of the database at > | http://www.windward.net/jdbc2.zip > | > | Note that the first row I inserted by hand - it was not created by your > | program. > | > | -- > | thanks - dave > | > | > > |
| |||
| Hi Dave, I'm not sure what's the difference between our DB. But since you mentioned that the hibernate component can correctly process the Unicode data through the jdbc driver, I'd recommend you have a look at hibernate's code. Is it source available? If not, you can consider using some decompiler such as the Djava tool to decompile the related class file to see what's the difference between your code and hibernate's code. 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: Asking again - ResultSet.getString() & unicode | thread-index: AcW3lq1e/d65l1dpS2qrNVZsyl78fQ== | X-WBNR-Posting-Host: 199.45.247.98 | From: "=?Utf-8?B?RGF2aWQgVGhpZWxlbg==?=" <thielen@nospam.nospam> | References: <CEFAD23A-E1BA-479B-9923-511D6FDCE30A@microsoft.com> <7PGnYcEtFHA.1252@TK2MSFTNGXA02.phx.gbl> <B25E4840-9D02-4372-A9FE-0DCD48456968@microsoft.com> <mrGDGPRtFHA.768@TK2MSFTNGXA01.phx.gbl> <10F8AE17-DDB4-41B8-8D74-783D97E9E80F@microsoft.com> <181272BD-5477-4ECC-94C2-EF3D54A0C08F@microsoft.com> <te8egO3tFHA.3160@TK2MSFTNGXA01.phx.gbl> | Subject: RE: Asking again - ResultSet.getString() & unicode | Date: Mon, 12 Sep 2005 05:37:03 -0700 | Lines: 116 | Message-ID: <4EC5B775-37CA-4D32-8890-8F5DD6B0FFFD@microsoft.com> | MIME-Version: 1.0 | Content-Type: text/plain; | charset="Utf-8" | Content-Transfer-Encoding: 7bit | 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:2695 | X-Tomcat-NG: microsoft.public.sqlserver.odbc | | Ok, here's some interesting results: | | First, please keep in mind that if I use hibernate (www.hibernate.org) I can | insert and select with no problems on my system. So I don't think it's a | configuration issue but instead some setting needed. | | If I add the N then it inserts fine. Obviously this doesn't help in the | select. | | If I create a database using BOPOMOFO for the collation, then if I insert | without the N, the chinese character inserts correctly, but the russian | character does not. The select still fails for both characters. | | So I think the answer for an insert is to use the N'unicode_string' as that | solves that problem. But to select, I still can't get it with | conn.createStatement(ResultSet.TYPE_SCROLL_INSENSI TIVE, | ResultSet.CONCUR_UPDATABLE) | | Any further ideas? | | -- | thanks - dave | | | "Steven Cheng[MSFT]" wrote: | | > Hi Dave, | > | > I still think the problem should be environment specific since on my local | > environment, no matter I use | > | > Statement stmt = conn.createStatement(); | > | > or | > | > Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSI TIVE, | > ResultSet.CONCUR_UPDATABLE); | > | > I can get the unicode string correctly from sqlserver. Also, for inserting, | > I can directly insert unicode in the following style: | > | > "\u98a8"; | > | > What's your database's Collation setting? Though from my test , this | > doesn't change the result, I think you can try set the collation to a | > codepage which can correctly interpret the wide chars. In addition, in | > T-SQL, when we inserting unicode string, it's recommended that we add "N" | > Prefix for each string value, so you can try using the following insert | > statement to see whether it can insert unicode correctly: | > | > public static boolean InsertNewUser (String name, String email) throws | > Exception{ | > | > Connection conn = getConnection(); | > | > String sql = "insert g_user values(N'" + name + "', N'" + | > email + "')"; | > | > .................................... | > | > } | > | > | > Hope helps. 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: Asking again - ResultSet.getString() & unicode | > | thread-index: AcW1eMlyyC/Dmw/1QQyoC1z0+TfdCA== | > | X-WBNR-Posting-Host: 199.45.247.98 | > | From: "=?Utf-8?B?RGF2aWQgVGhpZWxlbg==?=" <thielen@nospam.nospam> | > | References: <CEFAD23A-E1BA-479B-9923-511D6FDCE30A@microsoft.com> | > <7PGnYcEtFHA.1252@TK2MSFTNGXA02.phx.gbl> | > <B25E4840-9D02-4372-A9FE-0DCD48456968@microsoft.com> | > <mrGDGPRtFHA.768@TK2MSFTNGXA01.phx.gbl> | > <10F8AE17-DDB4-41B8-8D74-783D97E9E80F@microsoft.com> | > | Subject: RE: Asking again - ResultSet.getString() & unicode | > | Date: Fri, 9 Sep 2005 12:58:03 -0700 | > | Lines: 10 | > | Message-ID: <181272BD-5477-4ECC-94C2-EF3D54A0C08F@microsoft.com> | > | MIME-Version: 1.0 | > | Content-Type: text/plain; | > | charset="Utf-8" | > | Content-Transfer-Encoding: 7bit | > | 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:2691 | > | X-Tomcat-NG: microsoft.public.sqlserver.odbc | > | | > | Sometimes a picture shows things a lot better so you can find your code | > with | > | some minor changes I made, and screen shots of the database at | > | http://www.windward.net/jdbc2.zip | > | | > | Note that the first row I inserted by hand - it was not created by your | > | program. | > | | > | -- | > | thanks - dave | > | | > | | > | > | |
| ||||
| Hi; I stepped through the hibernate code. They call conn.createStatement() which works for me too. The problem is when I call conn.createStatement(ResultSet.TYPE_SCROLL_INSENSI TIVE, | ResultSet.CONCUR_UPDATABLE) - that then has the problem on calling getString(). If conn.createStatement(ResultSet.TYPE_SCROLL_INSENSI TIVE, | ResultSet.CONCUR_UPDATABLE) works for you then that is the difference between our systems. Can you ask the JDBC team if they can reproduce this? -- thanks - dave "Steven Cheng[MSFT]" wrote: > Hi Dave, > > I'm not sure what's the difference between our DB. But since you mentioned > that the hibernate component can correctly process the Unicode data through > the jdbc driver, I'd recommend you have a look at hibernate's code. Is it > source available? If not, you can consider using some decompiler such as > the Djava tool to decompile the related class file to see what's the > difference between your code and hibernate's code. > > 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: Asking again - ResultSet.getString() & unicode > | thread-index: AcW3lq1e/d65l1dpS2qrNVZsyl78fQ== > | X-WBNR-Posting-Host: 199.45.247.98 > | From: "=?Utf-8?B?RGF2aWQgVGhpZWxlbg==?=" <thielen@nospam.nospam> > | References: <CEFAD23A-E1BA-479B-9923-511D6FDCE30A@microsoft.com> > <7PGnYcEtFHA.1252@TK2MSFTNGXA02.phx.gbl> > <B25E4840-9D02-4372-A9FE-0DCD48456968@microsoft.com> > <mrGDGPRtFHA.768@TK2MSFTNGXA01.phx.gbl> > <10F8AE17-DDB4-41B8-8D74-783D97E9E80F@microsoft.com> > <181272BD-5477-4ECC-94C2-EF3D54A0C08F@microsoft.com> > <te8egO3tFHA.3160@TK2MSFTNGXA01.phx.gbl> > | Subject: RE: Asking again - ResultSet.getString() & unicode > | Date: Mon, 12 Sep 2005 05:37:03 -0700 > | Lines: 116 > | Message-ID: <4EC5B775-37CA-4D32-8890-8F5DD6B0FFFD@microsoft.com> > | MIME-Version: 1.0 > | Content-Type: text/plain; > | charset="Utf-8" > | Content-Transfer-Encoding: 7bit > | 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:2695 > | X-Tomcat-NG: microsoft.public.sqlserver.odbc > | > | Ok, here's some interesting results: > | > | First, please keep in mind that if I use hibernate (www.hibernate.org) I > can > | insert and select with no problems on my system. So I don't think it's a > | configuration issue but instead some setting needed. > | > | If I add the N then it inserts fine. Obviously this doesn't help in the > | select. > | > | If I create a database using BOPOMOFO for the collation, then if I insert > | without the N, the chinese character inserts correctly, but the russian > | character does not. The select still fails for both characters. > | > | So I think the answer for an insert is to use the N'unicode_string' as > that > | solves that problem. But to select, I still can't get it with > | conn.createStatement(ResultSet.TYPE_SCROLL_INSENSI TIVE, > | ResultSet.CONCUR_UPDATABLE) > | > | Any further ideas? > | > | -- > | thanks - dave > | > | > | "Steven Cheng[MSFT]" wrote: > | > | > Hi Dave, > | > > | > I still think the problem should be environment specific since on my > local > | > environment, no matter I use > | > > | > Statement stmt = conn.createStatement(); > | > > | > or > | > > | > Statement stmt = > conn.createStatement(ResultSet.TYPE_SCROLL_INSENSI TIVE, > | > ResultSet.CONCUR_UPDATABLE); > | > > | > I can get the unicode string correctly from sqlserver. Also, for > inserting, > | > I can directly insert unicode in the following style: > | > > | > "\u98a8"; > | > > | > What's your database's Collation setting? Though from my test , this > | > doesn't change the result, I think you can try set the collation to a > | > codepage which can correctly interpret the wide chars. In addition, in > | > T-SQL, when we inserting unicode string, it's recommended that we add > "N" > | > Prefix for each string value, so you can try using the following insert > | > statement to see whether it can insert unicode correctly: > | > > | > public static boolean InsertNewUser (String name, String email) throws > | > Exception{ > | > > | > Connection conn = getConnection(); > | > > | > String sql = "insert g_user values(N'" + name + "', N'" > + > | > email + "')"; > | > > | > .................................... > | > > | > } > | > > | > > | > Hope helps. 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: Asking again - ResultSet.getString() & unicode > | > | thread-index: AcW1eMlyyC/Dmw/1QQyoC1z0+TfdCA== > | > | X-WBNR-Posting-Host: 199.45.247.98 > | > | From: "=?Utf-8?B?RGF2aWQgVGhpZWxlbg==?=" <thielen@nospam.nospam> > | > | References: <CEFAD23A-E1BA-479B-9923-511D6FDCE30A@microsoft.com> > | > <7PGnYcEtFHA.1252@TK2MSFTNGXA02.phx.gbl> > | > <B25E4840-9D02-4372-A9FE-0DCD48456968@microsoft.com> > | > <mrGDGPRtFHA.768@TK2MSFTNGXA01.phx.gbl> > | > <10F8AE17-DDB4-41B8-8D74-783D97E9E80F@microsoft.com> > | > | Subject: RE: Asking again - ResultSet.getString() & unicode > | > | Date: Fri, 9 Sep 2005 12:58:03 -0700 > | > | Lines: 10 > | > | Message-ID: <181272BD-5477-4ECC-94C2-EF3D54A0C08F@microsoft.com> > | > | MIME-Version: 1.0 > | > | Content-Type: text/plain; > | > | charset="Utf-8" > | > | Content-Transfer-Encoding: 7bit > | > | 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:2691 > | > | X-Tomcat-NG: microsoft.public.sqlserver.odbc > | > | > | > | Sometimes a picture shows things a lot better so you can find your > code > | > with > | > | some minor changes I made, and screen shots of the database at > | > | http://www.windward.net/jdbc2.zip > | > | > | > | Note that the first row I inserted by hand - it was not created by > your > | > | program. > | > | > | > | -- > | > | thanks - dave > | > | > | > | > | > > | > > | > > |