ResultSet.getString(String) doesn't return the right text from database

Hi everybody,
I'm trying to read some text in Portuguese from a MS-Access database, but the special characters for Portuguese aren't correctly translated by ResultSet.getString(String).
Here's my piece of code:
private static void fetchEquipamentoEstabelecimento()
try
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(
" SELECT Eqp.NumSerie, Eqp.Estabelecimento, Estab.Nome, Estab.Cidade, Eqp.Data, Eqp.LPN " +
" FROM Equipamento Eqp, Estabelecimento Estab " +
" WHERE TabPreco = 23 " +
          " AND Eqp.Estabelecimento = Estab.Estabelecimento " +
"ORDER BY NumSerie DESC");
while(rs.next())
String nome = rs.getString("Nome");
System.out.println(rs.getLong("NumSerie")      + " " +
                         rs.getDate("Data")           + " " +
                         rs.getString("LPN")           + " " +
                         nome                              + " " +
                         rs.getString("Cidade"));
stmt.close();
catch(SQLException ex)
printSQLException("fetchEquipamentoEstabelecimento()", ex);
The output of this piece of code is 1 record joined from tables Equipamento and Estabelecimento:
111222333 2001-12-15 JHK Pal<X>cio Cristal Guarda
where the <X> is the greek letter beta. I was expecting a
portuguese character which is an a with an accent: � (I hope the character was correctly displayed for you)
I tried replacing
String nome = rs.getString("Nome");
with
String nome = new String(rs.getString("Nome").getBytes(),codepage);
with codepage="Cp860" (MS-DOS Portuguese)
and codepage="Cp037" (USA, Canada (Bilingual, French), Netherlands, Portugal, Brazil, Australia)
but other strange characters were displayed instead of the a with an accent.
In the MS-Access table Estabelecimento, the column Nome has a Data Type of Text.
I'm using:
- JDK 1.2.2
- MS Access 2000 (in Windows 2000)
MS Access 97 (in Windows NT 4.0).
Any help is deeply apreciated.

Hi!
When you establish connection to database, try explicitly give instructions about what encoding use your DB, e.g.:
// connection properties
Properties connInfo = new Properties();
connInfo.put("user", username);
connInfo.put("password", password);
connInfo.put("charSet", "Cp1251"); // enter your codepage!!!
// getconnection
Connection db = DriverManager.getConnection(dataurl, connInfo);

Similar Messages

  • Column exist but ResultSet.getString(String) return invalid column name

    With oracle 7 db the ResultSet.getString(String) works fine but after the upgrade to oracle 8 db it return invalid column name. ResultSet.getString(int) method works fine.
    Is this a bug in the driver?
    Thanks
    -Reda

    Yes I'm 100 % sure that the columns exist.
    -RedaWell then maybe it's a bug in the Oracle driver. Lord knows it wouldn't be the first time that's happened.

  • How can i get the correct text from a string like it show in the original source with the quotation marks in the right place ?

    The text is in hebrew so the problem is that sometimes the quotation marks not in the right place.
    For example i have this text: תווית
    על בגד: ''תן לאישה לכבס. זה תפקידה''
    This is the source original text you can see the quotations marks and they are not in the right place and all i did is copy paste.
    And this is a screenshot of how this text looks like in the website in the original:
    You can see now where the quotations marks should be.
    Now this is how i'm using the text in my program:
    First of all i'm using a webclient to download the page from the website and i'm also encoding it to windows-1255 since it's in hebrew.
    using (var webClient = new WebClient())
    webClient.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
    byte[] myDataBuffer = webClient.DownloadData("http://rotter.net/scoopscache.html");
    page = Encoding.GetEncoding("windows-1255").GetString(myDataBuffer);
    Then i'm extracting the places i need by reading the html file lines and parsing the right text and it's link.
    string loc;
    List<string> metas = new List<string>();
    List<string> metas1 = new List<string>();
    List<string> lockedLinks1 = new List<string>();
    string text = "";
    string mys = "";
    public List<string> LockedThreads(string filename)
    lockedThreads = new List<string>();
    lockedLinks = new List<string>();
    Regex textRegex = new Regex("ToolTip.*?(?=','<)");
    string[] fall = File.ReadAllLines(filename);
    for (int i = 0; i < fall.Length; i++)
    if (fall[i].Contains("http://rotter.net") && fall[i].Contains("locked")||
    fall[i].Contains("locked_icon_general") ||
    fall[i].Contains("locked_icon_anchor") ||
    fall[i].Contains("icon_anchor") ||
    fall[i].Contains("locked_icon_fire") ||
    fall[i].Contains("locked_icon_sport") ||
    fall[i].Contains("locked_icon_camera") ||
    fall[i].Contains("locked_icon_movie"))
    Regex linkParser = new Regex(@"\b(?:https?://|www\.)\S+\b", RegexOptions.Compiled | RegexOptions.IgnoreCase);
    foreach (Match m in linkParser.Matches(fall[i + 2]))
    if (m.Value.Contains("><b"))
    loc = m.Value.Replace("\"><b", string.Empty);
    lockedLinks.Add(loc);
    string txt = fall[i - 1];
    string text = textRegex.Match(txt).Value.Replace("ToolTip','", String.Empty);
    if (text.Contains("&rsquo;"))
    text = text.Replace("&rsquo;", string.Empty);
    lockedThreads.Add(text);
    Already here on the List lockedThreads you can see the quotation marks not in the right place as in the original:
    After i'm parsing the text and links and adding them to the Lists in another class i'm doing a comparison using this Lists:
    foreach (List<string> l_branch in ListsExtractions.responsers)
    TreeNode l_node = treeView1.Nodes.Add(l_branch[l_branch.Count - 1]);
    if (ListsExtractions.lockedThreads.Contains(l_node.Text))
    l_node.ImageIndex = 0;
    l_node.SelectedImageIndex = 0;
    for (int l_count = 0; l_count < l_branch.Count - 1; l_count++)
    TreeNode l_subnode = l_node.Nodes.Add(l_branch[l_count]);
    if (ListsExtractions.lockedThreads.Contains(l_subnode.Text))
    l_subnode.ImageIndex = 0;
    l_subnode.SelectedImageIndex = 0;
    The problem is in the line:
    if (ListsExtractions.lockedThreads.Contains(l_node.Text))
    When it's getting to the line with the quotation marks it's never equal.
    Now there are more quotation marks.
    In general the problem when comparing both text if it's having quotation marks it's not the same.
    So i have two options:
    1. To fix it somehow so the quotation marks will be the same in both variables when comparing and also the same like in the original as they show in the html page.
    2. To remove the quotation marks from both variables.
    What should i do ? And how ? I was prefer to use the original quotation marks like in the original since they have a meaning in the place they should be. The question is how can i do it ?
    This is example of the block from the html file where the text with the quotation marks is:
    <TD ALIGN="RIGHT" VALIGN="TOP">&nbsp;<font size=-1 color=#ff9933><b>9418</b></font>&nbsp;</TD></TR><TR BGCOLOR="#eeeeee">
    <TD ALIGN="RIGHT" VALIGN="TOP">
    <body onmousemove="overhere()">
    <a onmouseover="EnterContent('ToolTip','תווית על בגד: &rsquo;&rsquo;תן לאישה לכבס. זה תפקידה&rsquo;&rsquo;','<u><span style=color:#000099;>כתב: Spook בתאריך: 08.03.15 שעה: 22:11</span></u><br>מחאת טוויטר קמה בעקבות תוויות שוביניסטיות שהדפיסה חברת אופנה באינדונזיה לפיהן תפקיד הכביסה מוטל על האישה. החברה התנצלה אך כנראה רק עשתה רק יותר נזק לע...'); Activate();" onmouseout="deActivate()" href="javascript:void(0)">
    <img src="http://rotter.net/forum/Images/new_locked_icon_general.gif" border="0"></a></TD><TD ALIGN="right" VALIGN="TOP" WIDTH="55%">
    <FONT CLASS='text15bn'><FONT FACE="Arial">
    <a href="http://rotter.net/cgi-bin/forum/dcboard.cgi?az=read_count&om=189696&forum=scoops1"><b>
    <font color="898A8E">תווית על בגד: ''תן לאישה לכבס. זה תפקידה''</b>
    </a></font></TD>

    Ok, it is unclear on what is happening here.
    Are you saying that when the webclient gets the data that it is not honoring the quote characters? Or the processing of the data buffer is causing issues?
    This is what I see the of your example text which is trying to be parse out:
    <a onmouseover="EnterContent('ToolTip','תווית על בגד: &rsquo;&rsquo;תן לאישה לכבס. זה תפקידה&rsquo;&rsquo;','<u><span style=color:#000099;>כתב: Spook בתאריך: 08.03.15 שעה: 22:11</span></u><br>מחאת טוויטר קמה בעקבות תוויות שוביניסטיות שהדפיסה חברת אופנה באינדונזיה לפיהן תפקיד הכביסה מוטל על האישה. החברה התנצלה אך כנראה רק עשתה רק יותר נזק לע...'); Activate();">";
    It appears to me that the  escapes `&rsquo;` does not have matching `&ldquo;` anywhere within the tooltip. So it appears that the page properly places left quotes in when processing the page, but the raw html has broken text.
    Hence a garbage in, garbage out situation.
    William Wegerson (www.OmegaCoder.Com)

  • The product I bought its not working as i expected, it doesn´t translate the exact information from pdf to excel, how can you help me or how can you return my money back....

    how can you help me

    What about adobé export PDF. ?
    Enviado desde mi iPhone
    El 07/05/2014, a las 23:00, Claudio González <[email protected]> escribió:
    The product I bought its not working as i expected, it doesn´t translate the exact information from pdf to excel, how can you help me or how can you return my money back....
    created by Claudio González in Adobe Reader - View the full discussion
    If you bought Reader, you were swindled, because it's a free program. And it has never been able of converting PDF files to any other format.
    Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at https://forums.adobe.com/message/6363992#6363992
    Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page:
    To unsubscribe from this thread, please visit the message page at . In the Actions box on the right, click the Stop Email Notifications link.
    Start a new discussion in Adobe Reader by email or at Adobe Community
    For more information about maintaining your forum email notifications please go to http://forums.adobe.com/thread/416458?tstart=0.

  • The same selection doesn't return the same result in 2 identical systems

    Hi,
    After a copy we have 2 systems with same data.
    In a program the same selection doesn't returns the same result, it seems that the sort is different.
    I have checked indexes but they are ok in both systems.
    Here is the selection:
    SELECT but000~partner
    INTO TABLE lt_partner
    *UP TO 50 ROWS
    FROM but000
    JOIN but020
      ON but020partner = but000partner
    JOIN adrc
      ON adrcaddrnumber = but020addrnumber
    JOIN but100
      ON but100partner = but000partner
      WHERE but020~addr_valid_from LE '20100727000000'
      AND   but020~addr_valid_to   GE '20100727000000'.
    Is there a customizing point to define how the database must be sorted ?
    Thanks.
    Edited by: julien schneerberger on Jul 27, 2010 4:18 PM

    Hi,
    Thank you for your answer.
    Result is the same and I don't sort data after the selection.
    Do you think the system copy has "broke" the records order in database ?
    If it is the case it will be impossible to reproduce the same sort, is it right ?
    Edited by: julien schneerberger on Jul 27, 2010 5:19 PM
    Edited by: julien schneerberger on Jul 27, 2010 5:20 PM

  • My dad can't remember his iCloud password, and doesn't have the right answers to his security questions. Any other ways to reset a password?

    My dad can't remember his iCloud password, and doesn't have the right answers to his security questions. Any other ways to reset a password?

    Open > http://iforgot.apple.com and choose Email authentication

  • Click on a cell in formula doesn't return value, only text. why?

    When doing a simple formula like =c4-c5 in one of my sheets, when i click on the cell, it doesn't return the value, only text.
    What setting do i have enabled/disabled?
    thanks
    hamdog

    HI Hamdog,
    What you are seeing is the formula that is in that cell.
    The setting you have turned on is the first one in the bottom section of the General page of Numbers Preferences. In the English versions, it looks like this:
    With the checkbox unchecked (as mine is), the formula would read:
    =L10-P10
    Column L is labeled "Tips", Column P is labeled "Lenka", Row 10 is labeled "9. 2. 2013"
    To Copy and Paste the result, 462, click (once) on the cell and Copy, then click (once) on the cell where you want to paste the result and go Edit > Paste Values. This should be the seventh item (not including the separator line) in the Edit menu.
    Regards,
    Barry
    Regards,
    Barry

  • How to return the entire row from a table

    Hi guys,
    Tabl A
    FirstName varchar2(10),
    Age Number,
    Add varchar2(100),
    Table B
    Filedname varchar2(200), -- contains all the fields of table A
    Datatype varchar2(100), -- Contains the datatypes of the filedname
    Length Number -- contains the length of the fileds
    Now how can i return the entire row from table A with the datatype and its length.
    Any help would be appreciated ?
    Here is the query I wrote but it how to take the datatype and its length..
    create or replace procedure disp_table_data
    as
    type r_cursor is REF CURSOR;
    c_A r_cursor;
    er A%rowtype;
    begin
    open c_A for select * from A;
    loop
    fetch c_A into er;
    exit when c_A%notfound;
    dbms_output.put_line(er.FirstName||'--'||er.Age);
    end loop;
    close c_A;
    END;
    /

    Guys,
    I want column value from table A and its corresponding data_type and length from table B. I think I cant do it through joins.
    Any idea would be appreciated ?.
    Example ..
    Tabl A
    FirstName varchar2(10),
    Age Number,
    Add varchar2(100)
    insert into A values('John',24,'Boston');
    Table B
    Filedname varchar2(200), -- contains all the fields of table A
    Datatype varchar2(100), -- Contains the datatypes of the filedname
    Length Number -- contains the length of the fileds
    insert into B values('FirstName','varchar2',10); -- this is coming from table A.
    Output should be like this...
    John,Varchar2,10
    Here (John is the FirstName - coming from table A, Varchar2 is a Datatype and 10 is the Length which are coming from table B ). Only column values are coming from table A , corresponding datatype and length are coming from B.
    Any idea would be appreciated ?
    Thanks.

  • HT3529 My iPod doesn't deliver the messages sent from Messages, what do I do?

    My iPod doesn't deliver the messages sent from Messages, what do I do? I've tried everything, from restoring it to simply restarting it.

    You cannot update your ipod from the ipod itself.  This is only possible once you have ios 5.
    You update it the you always have.  Open itunes, connect ipod.  It will prompt you to update, if an update is available.
    If you have the 1st gen ipod touch, then you have the latest upate:  3.1.3

  • Where do the rights come from ...

    Hello, I'm running an MSSQL 2008 server with windows authentification only.
    I'm doing some cleaning in my security. I've set up some user groups in active direcory, and give them rights in sql server.
    The problem is: some user, with (apprently) no rights can still connect to databases.
    First: Do I have to create an explicit rule to forbid access to anyone ?
    Second: how do I know where the rights come from ?
    Thanks
    Alain

    Run the below query
    xp_logininfo 'Domain\user', 'all'
    This command should give you all the groups via the account has access to SQL.
    If the user has a login access then they get the minimum permissions with the public role. Apart from that they only will get access if we give specific permissions. If they are part of a group and if group has access to read/write for example and you dont
    want that to happen on specific tables then you can restrict the access.
    Regards, Ashwin Menon My Blog - http:\\sqllearnings.com

  • How can I remove the 'Qty' text from individual product descriptions?

    I didn't know if this was possible or not... I've recently taken the reins of handling an ecommerce site that had been published before I got on board. My boss wants me to remove the 'Qty:' description from some products because the image shown for some products is a misleading description of the actual quantity available (i.e. there is a picture that shows a stack of conveyors parts, and it says 'Qty: 1' to represent one 'stack' of conveyor parts - this confuses customers into thinking there's only one individual conveyor part available however). To avoid any confusion he requested that I remove the 'Qty' text from similar images. I see that you can change the 'In Stock' amount of a particular product underneath the 'Inventory' tab of the 'Products' menu, but I didn't know if it was possible just to remove the quantity description altogether without just typing the quantity in at zero. This is likely a strange question but I didn't know where else to ask! I would appreciate any help or advice Thank you

    Hi ewhelhalu,
    I just figured out a way to do it, but it's a little weird and complex, and I have no idea what the consequences for editing this .plist string might be. I'm thinking it'll be OK, but you never know what might happen when you screw around with Apple's intentions.
    So if you have the Developer Tools on your install of OS X, you can use the Property List Editor to edit the Dock files. (If you don't have this program, you can use a program like [Pacifist|http://www.charlessoft.com> to selectively install stuff from your Leopard disk).
    The file you're interested in is within Macintosh HD > Users > Your Username > Library > Preferences, and it's called com.apple.dock.plist. Open that up with Property List Editor, and open the arrow drop-down next to "Root." The lines you're looking for are "persistent-apps" (the left side of your Dock) and "persistent-others" (the right side). If you open the drop-down arrows, you'll see there are numbers below each. The numbers correspond to your Dock items, from left to right.
    If you click on drop-arrows by the numbers, a sample hierarchy looks like this: 0 > tile-data > file-label. It's the "file-label" string that you want to edit. Just make it ("it" being the name of the icon under the "value" column) blank, save the file, go into Terminal and type "killall Dock" without the quotes, and your Dock icon should appear without a name. You'll have to do this for all of them.
    I should insert the usual caveats here about backing up beforehand and making sure that you have a copy of the .plist file before you start tweaking it so that you can replace it if things go wrong. And perhaps someone with more knowledge of Terminal or third-party apps than I have will come along and suggest a simpler solution. But that's the only one I have.
    Hope that helps!
    —Hazy

  • When I am on my home screen on the iPhone, swipe left to the search page. Put a letter in the search field. then scroll down. eventually you get to all your texts previously deleted or not. The are all there. How can I clear the entire text from the phone

    When I am on my home screen on the iPhone, swipe left to the search page. Put a letter in the search field. then scroll down. eventually you get to all your texts previously deleted or not. The are all there. How can I clear the entire text from the phone

    When I am on my home screen on the iPhone, swipe left to the search page. Put a letter in the search field. then scroll down. eventually you get to all your texts previously deleted or not. The are all there. How can I clear the entire text from the phone

  • Automatically copy only the unicode-Text from a Word-Document into FM8

    In my daily work I often have the problem to copy and paste text from a  Word-Document or other documents into my FrameMaker documents.
    The common way is to copy it in Word and "Special Paste" it in FrameMaker 8 as unicode. But this is not as confortable as to shortly hit Ctrl-v on the keyboard.
    I would like to have a new menuitem to special paste only the unicode text from the clipbopard. Is there a way to make such a makro and to put it in the menubar with a Key-Trigger?
    I read something like that in http://www.rzg.mpg.de/from_external/Frame6_Handbuch/Setting_up_FrameMaker.pdf (german), but I actually don't know what to chage for my case.

    Rather than create a new menu item (possible, I gather, but fiddly) I would recommendchanging the default “paste” behaviour.
    In the MAKER.INI file there is a line beginning
    ClipboardFormatsPriorities=
    Change this to put UNICODE TEXT as the first item.
    Ctrl-v will then paste Unicode text by default. You can still access the other options, should you need to, by using Paste Special.

  • HOW TO TRANSPORT THE STANDARD TEXT FROM ONE SERVER TO ANOTHER?

    After creating the standard text in SO10 transaction
    it will not ask for any transport request no while saving ,
    i want to transport the standard text from development to test server.
    how can we do that?

    Hi Riaz,
    To transport a Standard Text through a transport request , you need to attach the standard text through the transaction RSTXTRAN.
    After executing the report RSTXTRAN , you can enter first the task name then the Object as TEXT , then the name of the standard text , ID as ST, then the language as EN or something else .then execute.
    you cannot attach a standard text to an unassigned task.Firat you have to either activate a smartform or a script with that task then only you have to attach a standard text.
    I think your query is almost answered .
    Reward if you please.
    Thanks & regards,
    Ram

  • I want to delete the transactional record from database table

    Hai,
    I want to delete the transactional data from database table with out using the dialog programming is it there any trancation for this.
    for master data we have the transaction code for delete the records. The t.code is 'OBR2'.
    Plz help in that cse.
    Thanks and regards,
    P.Naganjana Reddy

    Hai,
    Plz help me urgent.
    I am asking i want to delete transactional data from database table without using the dialog programming.
    Thanks and Regards,
    P.Naganjana

Maybe you are looking for