Trying to get UTF-8 data in and out of an oracle.xdb.XMLType

I need to be able to put unicode text into an oracle.xdb.XMLType and
then get it back out. I'm so close but it's still not quite working.
Here's what I'm doing...
// create a string with one unicode character (horizontalelipsis)
String xmlString = new String(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<utf8>\n" +
" <he val=\"8230\">\u2026</he>\n" +
"</utf8>\n");
// this is an oci8 connection
Connection conn = getconnection();
// this works with no exceptions
XMLType xmlType = XMLType.createXML(conn, xmlString);
// this is the problem here - BLOB b does not contain all the bytes
// from xmlType. It seems to be short 2 bytes.
BLOB b = xmlType.getBlobVal(871);
String xmlTypeString = new String(b.getBytes(1L, (int) b.length()), "UTF-8");
PrintStream out = new PrintStream(System.out, true, "UTF-8");
out.print(xmlTypeString);
out.close();
What I get from this is this...
<?xml version="1.0" encoding="UTF-8"?>
<utf8>
<he val="8230">[utf-8 bytes]</he>
</utf8
In the above, [utf-8 bytes] represents the correctly encoded UTF-8 bytes that
were returned. But the output is missing the final closing bracket and the
newline at the end. It seems that no matter what second argument I give b.getBytes(),
it always returns the above. Even
It seems that this code...
BLOB b = xmlType.getBlobVal(871);
always returns a BLOB that contains a few bytes short of what it should contain.
What am I doint wrong? I'm sure I'm missing something here.
Thanks much for your help.
Here's info about the environment I'm working in.
============================ SYSTEM INFORMATION ============================
SQL*Plus: Release 11.1.0.7.0 - Production on Fri May 15 11:54:34 2009
select * from nls_database_parameters
where parameter='NLS_CHARACTERSET'
returns...
WE8ISO8859P1
select * from nls_database_parameters
where parameter='NLS_NCHAR_CHARACTERSET'
returns...
AL16UTF16
The operating system I'm working with is...
SunOS hostname 5.10 Generic_120011-14 sun4u sparc SUNW,Netra-T12

WE8ISO8859P1 does not support the ellipsis character. It is a WE8MSWIN1252 character. I wonder if your problem may have something to do with internal conversion to/from XML character reference (&#x2026). Unfortunately, I have no time to test. Please, try to use a simple loop and System.out.print to print all bytes of the return value of b.getBytes(1L, (int) b.length()). Also, check the value of b.length().
-- Sergiusz

Similar Messages

  • How do I get unicode characters out of an oracle.xdb.XMLType in Java?

    The subject says it all. Something that should be simple and error free. Here's the code...
    String xml = new String("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<x>\u2026</x>\n");
    XMLType xmlType = new XMLType(conn, xml);
    conn is an oci8 connection.
    How do I get the original string back out of xmlType? I've tried xmlType.getClobVal() and xmlType.getString() but these change my \u2026 to 191 (question mark). I've tried xmlType.getBlobVal(CharacterSet.UNICODE_2_CHARSET).getBytes() (and substituted CharacterSet.UNICODE_2_CHARSET with a number of different CharacterSet values), but while the unicode characters are encoded correctly the blob returned has two bytes cut off the end for every unicode character contained in the original string.
    I just need one method that actually works.
    I'm using Oracle release 11.1.0.7.0. I'd mention NLS_LANG and file.encoding, but I'm setting the PrintStream I'm using for output explicitly to UTF-8 so these shouldn't, I think, have any bearing on the question.
    Thanks for your time.
    Stryder, aka Ralph

    I created analogic test case, and executed it with DB 11.1.0.7 (Linux x86), which seems to work fine.
    Please refer to the execution procedure below:
    * I used AL32UTF8 database.
    1. Create simple test case by executing the following SQL script from SQL*Plus:
    connect / as sysdba
    create user testxml identified by testxml;
    grant connect, resource to testxml;
    connect testxml/testxml
    create table testtab (xml xmltype) ;
    insert into testtab values (xmltype('<?xml version="1.0" encoding="UTF-8"?>'||chr(10)||'<x>'||unistr('\2026')||'</x>'||chr(10)));
    -- chr(10) is a linefeed code.
    commit;
    2. Create QueryXMLType.java as follows:
    import java.sql.*;
    import oracle.sql.*;
    import oracle.jdbc.*;
    import oracle.xdb.XMLType;
    import java.util.*;
    public class QueryXMLType
         public static void main(String[] args) throws Exception, SQLException
              DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
              OracleConnection conn = (OracleConnection) DriverManager.getConnection("jdbc:oracle:oci8:@localhost:1521:orcl", "testxml", "testxml");
              OraclePreparedStatement stmt = (OraclePreparedStatement)conn.prepareStatement("select xml from testtab");
              ResultSet rs = stmt.executeQuery();
              OracleResultSet orset = (OracleResultSet) rs;
              while (rs.next())
                   XMLType xml = XMLType.createXML(orset.getOPAQUE(1));
                   System.out.println(xml.getStringVal());
              rs.close();
              stmt.close();
    3. Compile QueryXMLType.java and execute QueryXMLType.class as follows:
    export PATH=$ORACLE_HOME/jdk/bin:$PATH
    export LD_LIBRARY_PATH=$ORACLE_HOME/lib
    export CLASSPATH=.:$ORACLE_HOME/jdbc/lib/ojdbc5.jar:$ORACLE_HOME/jlib/orai18n.jar:$ORACLE_HOME/rdbms/jlib/xdb.jar:$ORACLE_HOME/lib/xmlparserv2.jar
    javac QueryXMLType.java
    java QueryXMLType
    -> Then you will see U+2026 character (horizontal ellipsis) is properly output.
    My Java code came from "Oracle XML DB Developer's Guide 11g Release 1 (11.1) Part Number B28369-04" with some modification of:
    - Example 14-1 XMLType Java: Using JDBC to Query an XMLType Table
    http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28369/xdb11jav.htm#i1033914
    and
    - Example 18-23 Using XQuery with JDBC
    http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28369/xdb_xquery.htm#CBAEEJDE

  • I was trying to get my personal computer contacts and calendar in outlook on my iphone and ipad.  I was told to use icloud.  I went to control panel and then icloud and selected my contacts and calendar.  Now ALL MY DATA IS DELETED FROM OUTLOOK.  Help!!

    I was trying to get my personal computer contacts and calendar in outlook on my iphone and ipad.  I was told to use icloud.  I went to control panel and then icloud and selected my contacts and calendar.  Now ALL MY DATA IS DELETED FROM OUTLOOK.  Help!!

    I was just on the line with Apple Tech support.  First of all, I learned that when you link contacts to iCloud, it moves all your contacts to another/new address book...look for aother address books and you will see it.  But I found the new address book dies weird things and changes the "Display Names" format.  Evidently (per Apple support tech) there is no way to avoid this problem...so I just delinked the iCloud from my contacts.  The contacts stayed in the iCloud address book...so I exported them to a CSV (comma separated value) file and saved it on my desktop and then imported that list into my original contacts folder.  Now everything is back the way it was...being able to use my contact address book the way I did before.  I was surprised that they never considered or realized this problem...but then the tech guy admitted that they really don't have A LOT of experience using Windows PC's.

  • I have an ipod touch 2nd generation, i'm trying to get apps that will work and i cant find any. Its says i need an update because it has ios 3.1.3 , but on itunes it says there is no update ? what apps can i get??

    i have an ipod touch 2nd generation, i'm trying to get apps that will work and i cant find any. Its says i need an update because it has ios 3.1.3 , but on itunes it says there is no update ? what apps can i get??

    Sounds like you actually have a 1st generation as those cannot update beyond iOS 3.1.3.
    Model Identifier Utility
    rachelfromnorthumberland wrote:
    what apps can i get??
    Finding iOS Apps Compatible with Older Devices

  • I recently subscribed to Adobe ExportPDF and tried to convert a PDF file to MS Word.  So far,  after many tries,  I get soe type of error and the conversion fails.  Please advise?

    I recently subscribed to Adobe ExportPDF and tried to convert a PDF file to MS Word.  So far,  after many tries,  I get soe type of error and the conversion fails.  Please advise?

    Hi there,
    It sounds like there may be an issue with the quality of the PDF. Not all PDFs are created equal, and especially those created from scanned documents can be problematic if the scan quality isn't the best. Is there a dark background on the PDF, or stray marks or smudges?
    You can try converting with OCR disabled at outlined in this document: How to disable Optical Character Recognition (O... | Adobe Community. But, while that's a good test to find out where the problem lies, you'll end up with a Word document that isn't editable, so it's not an optimal solution.
    Please let us know how it goes.
    Best,
    Sara

  • My itunes says that my iphone is synced with another itunes. It gives a name but how do i find out which library it is? I working with 2 computers trying to get music off of one and on to my new one.

    My itunes says that my iphone is synced with another itunes. It gives a name but how do i find out which library it is? I working with 2 computers trying to get music off of one and on to my new one.

    See Recover your iTunes library from your iPod or iOS device and this migrate iTunes library post.
    tt2

  • I am trying to get into my iCloud account and it is saying invalid user name and password

    I am trying to get into my iCloud account and it is saying "Invalid User Name or Password". I thought that you use your Apple I.D. and password, but that does not work! So, how do you reset your user name and/or password if you don't know what ones ICloud is seeking....

    After resetting your password you might then need to log out of your account on your device by phone on your id in Settings > Store (Settings > iTunes & App Stores if it's on iOS 6) and then log back in so as to 'refresh' the account on it
    If that doesn't fix it then you might need to contact iTunes Support : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page

  • Data objects and code objects in oracle application

    Hi,
    can any one please help me out with following question?
    1. what are data objects and code objects in oracle apps and why is that difference?
    2. How does the objects gets created in Oracle Applications, like during the installation which part is responsible for creating objects and after the installtion later point of time, how the new objects gets created in oracle applications?
    3. what are the ways to find out if my 11i application is OATM enabled ?
    Thanks in advance

    Hello,
    I managed to find answer for question 1, yet to find answer for 2 and 3.
    Answer for question 1 --
    Data objects : store and access business data (tables, indexes, sequences, index-organized tables, etc);
    Code objects : process data objects but them don't contains business data (functions, procedures, packages, views, synonyms);
    Now, here i have a question - under which objects queues are considered ?

  • Since downloading Yosemite 10.10.2, emails are not automatically downloaded.I have to either click on Get Mail or click in and out of mail inbox.

    Since downloading Yosemite 10.10.2, emails are not automatically downloading. I have to either click on Get Mail or click in and out om mailbox.
    It's very frustrating as it does not happen on my iPad or Iphone.

    Howdy welcon,
    It sounds like your Mail application is not checking for mail automatically anymore after updating to 10.10.2. It seems to me that the setting for this may have reset, or changed at some point thereafter so I would check the preferences for the Mail application:
    General preferences - Mail Help
    Check for new messages
    When Mail gets new messages from the mail server. By default, the option is set to Automatically (Mail varies how often it gets messages, based on whether your Mac is plugged into an electrical outlet).
    An IMAP account may get messages more frequently if the mail server supports the IDLE command; make sure the option to use it is selected in the account’s Advanced pane in Mail preferences.
    If you set the option to Manually, click the Get Mail button in the Mail toolbar to check for messages. (Whenever you click an IMAP or Exchange mailbox, it syncs with the server, and shows new messages.)
    Thank you for using Apple Support Communities.
    All the very best,
    Sterling

  • Have timesheet data. Trying to get staff at risk of burn out (worked 8hrs a day during last 3 weeks)

    Hi all,
    I've been trying to get a semi-complex measure out for over a day now but seem to be going round in circles. Most frustrating is I don't quite understand why one version throws an error, another throws out the wrong number and then whatever you guys come
    up with will give me the correct answer!
    I have a workbook uploaded here which I used for a different question, but majority of the data model is the same :
    https://onedrive.live.com/?cid=1C0322C61F94C9E9&id=1C0322C61F94C9E9%21125
    What I'm trying to do is find staff members that are at risk of burn out (eg consistently working > 8hrs a day)
    My main timesheet table (Time) is as such:
    StaffID (fk to staff table)
    ClientID (fk to client table)
    TaskID (fk to task table)
    TimesheetDate (fk to date table)
    EffortInHrs
    my date dim is standard fare, only thing i've added is an EndOfWeekDate (eg EOWDate. sunday is the last day therefore for each date for this week the endofweekdate column = 18-jan. For last week it was 11-Jan etc) and I also have a 'last freshed date' that
    shows the last time the model was refreshed
    A staff member can only record time against a specific task once per day, but they can have multiple tasks across multiple clients for one day
    The business rule im working with is
    if they've worked more than 8hrs at least once in the last 3 weeks (dates that fall between EOWdate for 'now' minus 3 weeks and EOWdate for 'now' ), then return the sum of EffortInHrs for all clients for every day in the last 3 weeks
    I've given up in getting it in one go so i'm trying to cobble together a number of calc columns and measures to get me closer.. but it all seems to stall
    eg the following calc column (DailySumOfHrs)
    =
    CALCULATE (
    SUM ( [EffortInHours] ),
    FILTER (
    ALLEXCEPT ( TIME, 'Time'[TimesheetDate], TIME[StaffID] ),
    DATESBETWEEN (
    'Date'[Date],
    'time'[TimesheetDate],
    'Time'[TimesheetDate]
    gives me the sum of effort in hrs for the day for each staff member. I couldn't get a measure version of this working. It would either aggregate across all days/staff or give context errors.
    So when I tried to take it to the next step to find the max using the same formula
    =
    CALCULATE (
    SUM ( [EffortInHours] ),
    FILTER (
    ALLEXCEPT ( TIME, 'Time'[TimesheetDate], TIME[StaffID] ),
    DATESBETWEEN (
    'Date'[Date],
    'time'[TimesheetDate],
    'Time'[TimesheetDate]
    I get errors, i'm guessing because i'm mixing my fact and date tables now and it doesn't know it can use the TimeSheetDate 'context' to filter.
    To get the 'last 3 weeks' filter working I added the following to the date dim
    =if([EndOfWeek]<[RefreshDateLocal] +7 && [EndOfWeek] > [RefreshDateLocal] -14,1,0)
    i then used it in an intermediate measure to get the max at the weekly grain
    WeeklyMax :=
    IF (
    MAX ( 'Date'[Last3WeeksFilter] ) = 1,
    CALCULATE (
    MAX ( TIME[DailySumOfHrs] ),
    FILTER (
    ALL ( 'Date'[date] ),
    MAX ( 'Date'[EndOfWeek] ) = MAX ( 'Date'[EndOfWeek] )
    'Date'[Last3WeeksFilter] = 1
    BLANK ()
    and finally the measure itself
    BurntOutHrs:=if([WeeklyMax]>8,SUM([EffortInHours]),blank())
    I am not happy with this at all. There are so many conditions (eg filters added) that need to be satisfied for this to return a sensible result and I need to expose a number of the 'backend' filters that users would need to add to the report to get the correct
    answer.
    As is, it only works for a simple Staff, date, burntouthrs report. If users attempt to create their own pivot table/chart and try to break it down by client or task it doesn't look right at all. I'd also like to be able to count how much stuff are working
    long hrs but this approach wouldn't support that at all.
    I could probably post dozens of my attempted dax that to me logically look like it should work but either aggregate wrong or throw context errors. Unfortunately my current approach to dax still is to try various, almost random variations until one works
    for whatever reason
    I always aim to have a measure that 'just works' in all contexts where it makes logical sense. For me to get that happening here i'd probably need to spend another few hrs trying all kinds of allexcept() conditions for each filter where i want it to work
    and hope none contradict each other
    Thinking about it now, this isn't really a separate measure at all.. i think a better approach would be to add a calc column to the staff table that checks if that staff member has >8hrs assigned for any day (i dont think the default time->staff relationship
    would allow this though). But i'm still interested on how to accomplish it using the separate 'measure' approach
    I'll go spend the rest of today trying to get the flag working in the staff dim!
    Thanks!
    Jakub @ Adelaide, Australia Blog

    Jakubk, is this still an issue?
    Thanks!
    Ed Price, Azure & Power BI Customer Program Manager (Blog,
    Small Basic,
    Wiki Ninjas,
    Wiki)
    Answer an interesting question?
    Create a wiki article about it!

  • Trying to get my air video app and my airport extreme router to work.

    Hi there. I am getting really frustrated and desperate. I just purchased the app "air video" on my iPad. Installed the software on my mac. Works awesome when I'm on MY WIRELESS NETWORK. I didn't think it would be an issue once I left the house and tried to go on someone else's network to connect, but it just won't work. It keeps giving me the error "host not reachable". I tried opening up the air video troubleshooting info and tried everything but nothing seems to work. I tried under the "remote" tab in the air video server preferences. I clicked both "enable access from Internet" and the "auto map port" options. In the box below I just see the word status and the spinning wheel along with "looking for UPnP or NAT-PMP compatible devices" but the wheel has been spinning for about 15 mins. It doesnt appear to be finding anything.
    I've also clicked off the "auto map port" to see if that would do anything. I got the pin and tried that. Still nothing. I tried to look for some information on port forwarding for my airport extreme but everything I'm googleing seems to be years out of date.
    I am currently on Mac snow leopard 10.6.3 I believe. Everything is latest version. Using comcast modem with apple airport extreme router. Latest version of Air video app and software. On iOS 4.3.1.
    Anyone that can try to help me out, I would be eternally grateful.
    Thank you so much
    Keith

    * need to edit to" trying to get my iPhone not iPhoto**"

  • Getting lots of data onto and off of the iPhone

    Suppose I write a program for the iPhone that does audio or video editing, or anything else that creates large files which users will want to move to their computers; or users might want to move large source files from their computers to their phone for use with the program. What are the options for doing this? I can think of 3 ways:
    1. Use web access to upload and download files. This could be time-consuming for the user and expensive for the app developer if users are going to be sending potentially gigabytes of information to and from my server.
    2. Build a desktop program that has its own web server, so users can connect to their desktop directly from the iPhone app, as long as they have wi-fi at home; but making it cross-platform would involve a lot of extra work.
    3. The best option I can think of would be to implement an AFS, NFS, or SMB server in the app, which would allow the computer to mount the iPhone as a share -- but specifically only the files in that application's data store. This would be awkward (without background processing, the user would have to leave the app open while accessing it from their computer) but it should work, and it doesn't appear to run afoul of Apple's SDK agreement. The question which I haven't looked into yet is: is it possible to open a TCP port to listen for connections on the iPhone, or only to make outgoing connections?
    4. Conversely, an AFS client in the app would let users connect to their desktop computer to pull files, but this seems less convenient.
    Can anyone think of other options I might have missed, that would make transferring large files less painful?
    (The obvious right answer would be for the phone to act as a USB drive when connected to the computer, as most iPods do, so that files could be easily copied on and off. The next best thing would be for iTunes to provide an option to sync third-party app data along with its own data, but I can't see any way to do this either.)
    <Edited by Moderator>

    if users are going to be sending potentially gigabytes of information to and from my server.
    If your users are going to try to do anything with gigabytes of information and the phone you have giga-problems. You might rethink what you're trying to do. There is VERY limited memory on the phone (20-30MB reasonable). The phone runs at 1/4 speed or less than the typical desktop system.
    You've outlined the main ways. Buy/download some of the file sharing or transfer type of apps to get a sense for them and their speed.

  • Trying to get into the app store and it asks for my password. The problem is that it is showing an Apple ID I don't use ghosted in. I can't figure out how to use my correct ID.

    Trying to get into the App Store to update some apss. It asks for my password but the problem is that it is showing ghosted an Apple ID I don't use. Can't figure out how to fix it.

    You installed a hacked app, originally from the Mac App Store. It contains the receipt for a different app, downloaded using an account that you don't control. You need to identify and remove the hacked app.
    Important: The app you need to remove is not necessarily the one named in the App Store alert. For example, if the App Store says you need to update "Twitter," the hacked app may be "Angry Birds" or something else entirely. Don't make any assumptions about which app you're looking for. To find it, you have to carry out a systematic search.
    Triple-click anywhere in the line of text below on this page to select it:
    kMDItemAppStoreHasReceipt=1
    Copy the selected text to the Clipboard by pressing the key combination command-C.
    In the Finder, press command-F to open a search window, or select
    File ▹ Find
    from the menu bar. In the search window, select
    Search: This Mac
    from the row of tokens below the toolbar. Below that is a popup menu initially showing Kind. From that menu, select  Other...
    A sheet will drop down. In that sheet, select Raw Query and click OK or press return.
    Now there will be a text box to the right of popup menu. Click in that box and paste (command-V).
    The search window will show all the App Store products you've installed. Compare those search results with the list of your purchases from the App Store. To see the complete list, you may need to unhide hidden purchases. If any apps were download from the App Store using other Apple ID accounts that you control, sign in to the store under each of those ID's and check the purchases.
    At least one of the items listed in the search window is not among your purchases in the App Store. Move each such item to the Trash. You may be prompted for your administrator password. Empty the Trash.
    Log out and log back in. Test.

  • Running Mavericks, I was trying to get messages to run ICQ and apparently I changed a setting that now causes me to get an error message and shuts messages down.

    I am running Mavericks.
    I was trying to get "Messages" to play nice with ICQ. it was sending HTML format to the receiver on the other end.
    I saw online how to change the item typed to show up as plain text on the for the recipient.
    Unwisely, I didn't follow ALL the instructions (where it told me to make a copy on my desktop "in case" and I changed one of the settings incorrectly.
    Now when I try to start Messages up, it opens briefly, then says it encountered an error and needs to shut down.
    I can remove Messages, but before I do, I can't seem to find a place to re-download it.
    Any suggestions on the best way of handling this?

    Hi,
    Once you get to Lion (OS X 10.7) and higher the only way is to Restore the whole OS as several Apple App are included this way and are not available separately.
    It should be just the .plists that are involved.
    The com.apple.imagent.plist holds the account info as it provides a "listening" function on all logins before your start up the app.
    I would delete this one as well.
    If that does not work repeat the process and delete com.apple.ichat.plist itself.
    7:20 pm      Monday; March 24, 2014
    ​  iMac 2.5Ghz i5 2011 (Mavericks 10.9)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
     Couple of iPhones and an iPad

  • Trying to get my videos off iphone and onto a dvd

    So I have a few questions..if anyone can help its so much appreciated!
    I am trying to get my iphoto videos onto a dvd with my macbook pro. Just bought IDVD. I made a dvd with a few clips just to make sure it worked and it worked good except....
    1. Do I really have to go to my external harddrive each time to import a video--I have 5 years worth so this takes to long. I tried to drag and drop from "Finder" but  it would not work for me. Any other ideas?
    2. When I put the dvd into my dvd player it worked although I had to go to the main menu for each video(some clips are very short) Is there a way before I complete the burn dvd process to set it where the videos run continously?
    3. The audio is a little low on the videos--anyway to make it louder(other than turning the tv up!?)
    thank you:)

    * need to edit to" trying to get my iPhone not iPhoto**"

Maybe you are looking for

  • Can i import "all images" into iphoto to create a new library?

    somehow about 4000 photos out of 10000 disappeared when I moved to the newest iphoto and attached my external hard drive with the old iphoto library to it and switched between libraries using alt to open it.  i was unable to get iphoto to see the mis

  • IPod recognized on one PC, but not on another

    Hi! I just received a brand new iPod Click Wheel 20GB in exchange for my old one that had a hardware defect within the warranty period. When I tried to connect the device to PC1 (WinXP) which I had always used with the old iPod without any problems,

  • How can I raise the volume on a video clip in Premiere Elements 12?

    I want to raise the volume on a video clip in Premiere Elements 12. Can anyone help?

  • Oracle 10g/ArcSDE 9.2

    During the installation of ArcSDE I keep getting the following error during the install. ESRI ArcSDE Server Setup Utility Tue Sep 04 13:18:34 2007 Creating ArcSde schema..... Successfully created ArcSde schema. Installing locators..... Successfully i

  • Gaussian blur and Colour Adjust Hue/Saturation cause freeze-up

    After using PS Elements 9 for a year, it has started to give me problems, and I can't find a fix for it online.  Choosing Gaussian Blur, or Color - Adjust Hue/Saturation causes PSE 9 to freeze up and stop responding.  This just started today, and I'm