Oracle 9i + Java: change the channel encoding UTF-16 for Windows-1251

Ladies and gentlemen,
I have a very urgent case: need to change the encoding of the string retrieved from the file (with the UTF-16 encoding) for Windows-1251 and put it in the db table, the CLOB field.

The Java function code
-----
+ file2table public static Sub (sql String, String fileName, String characterSet, int asByteArray) throws SQLException, IOException {+
Con connection = null;
Writer writer = null;
Reader reader = null;
+ try {+
con = getConnection().
PreparedStatement ps = con.prepareStatement (sql);

reader = new InputStreamReader (new buffer (new FileInputStream (new File (fileName))), characterSet);
BufferedReader BR = new BufferedReader (reader);
String ^ s;
+ While ((s = br.readLine ())! = null) {+
Byte [] defaultBytes = s.getBytes (characterSet);
String win1251str = new String (defaultBytes, "windows-1251" ');

+ if(asByteArray>0) {+
ps.setBytes (1, defaultBytes);
+ / ps.setBytes (1, win1251str.getBytes("windows-1251")); +
+} else {+
ps.setString (1 s);
+}+
ps.executeUpdate ();
+}+
con.Commit ();
+} Finally {+
+ if (reader! = null) {reader.close () ;} +}
+ If (con! = null) {con. Close ;} +
+}+
+}+
-----

I've been checking, all the bytes correctly received file. But if I put some bytes in the database table, the result in the table text is broken.

You prepare your unnecessarily complicated code, and you formatted as it look like sh * t.
Just read the file with

BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(fileName), characterSet));

Do not use getBytes() anywhere.
Do not use

new String(defaultBytes, "windows-1251");

any where.

If you intend to write the entire file in a single clob (now, you seem to be written each line of file in their own line of database), look instead of the setCharacterStream method and simply write characters directly here.

Here's more information: http://docs.oracle.com/cd/B19306_01/java.102/b14355/oralob.htm#i1058044

Published by: Kayaman on October 31, 2012 15:46

Tags: Oracle

Similar Questions

  • Change the channel of command USB for Tecra M2

    Hello

    Is it possible to move the USB controllers on another channel? I tried in vain to install a USB audio (M-Audio FastTrack) on my Tecra M2. Every time that I plug an error message is displayed in a bubble right - "a problem occurred during hardware installation. I called their tech support who told me that I have to contact Toshiba and ask how to channel 11 on a different channel USB drive. Can anyone help?

    Thank you
    Tom

    Hello

    In my case, it is not possible to change anything. The option to use the automatic settings is set and cannot be changed at all (gray).

    To view your current IRQ assignments, you can open the Device Manager.
    1. click on START, click on control PANEL.
    2. click on system.
    3. click on the Hardware tab.
    4. click on the button of DEVICE MANAGER.
    Once the Device Manager open, select VIEW from the menu of the toolbar, and then click resources by Type. Double-click the interrupt (IRQ) application and your current IRQ assignments will be shown.

    The list that appears on your machine will vary depending on the hardware you have.
    If you are faced with a conflict and you need to change an IRQ setting:
    1. right click on the device in the list (see above), and then select Properties.
    2. click on the "resources" tab.
    3. uncheck the option use automatic settings.
    4. Select a non conflicting configuration in unrolling of the box.
    5. click on OK
    You may find that you cannot manually change IRQ settings (use of automatic settings will be grayed out), this is usually related to the ACPI function used by Win XP as in my case.

    Note Please change system resources such as the IRQ channels can cause your computer not to work does not correctly; always take note settings before changing anything, so you can restore them if necessary.

    Good bye

  • Change the mailto: link Outlook Desktop for Windows 8 Mail app

    After you have installed Office 365 in Windows 8, the desktop version of Outlook took the "mailto:" links from other applications and Web sites. I want to continue to use the Windows 8 Mail application. Is it possible to change this setting?

    1. move your pointer to the bottom left of the screen, right-click and then select Control Panel then select default programs.

    2. Select set your default program settings.

    3. Select the mail on the left.

    4. Select set this program as default.

    5. click on OK.

    For the Mail app this only associates the mailto: Protocol. It does not send an email page/link for the e-mail application.

  • How can I change the city weather Bing desktop for windows 7?

    From Seattle to Boston?

    See this help

    http://onlinehelp.Microsoft.com/en-us/Bing/gg316390.aspx?SL=1

  • Airport utility does not support my Airport - options to change the channel?

    I have an older Airport - extreme, I think, and the utility does not support.  I'm out of luck to change channel?  Time Warner said their modem did not support my newest Airport (? it's TWC) and now the internet keeps smoking at least once or twice a day.

    I suggest that you keep it simple.

    Your airport automatically analyze and choose the best channel to use when it lights up. So, if you have not done for some time, powering to the airport, wait a few seconds and then put it to the top.

    Even if you could change the channel... How would you know which channel to choose?

    Time Warner said that their modem did not support my most recent airport

    Time Warner will only support for a product they have received for you.  But this does not mean that a router from Apple will not work with their service. I've used Apple products for over 10 years with Time Warner.

  • How to change the channel of my SONY HDR-CX440 wireless?

    I'm live streaming video from my sony HDR-Cx440 to an iPAD using app "playmemories Mobile". Communication between these two seems to be on Channel 6 and which interferes with my other wireless devices. I want to change the channel from 6 to any other channel wireless. How can I do?

    Salvation TV,.

    Welcome to the community of Sony!

    We're sorry, but there is no way to change the configuration wireless from the camera to a different channel.

    If my post answered your question, please mark it as "accept as a Solution. Thanks_Mitch

  • Restart the computer when changing the channel of live TV

    I am running Windows Media Center 2002 Service pack 3 on my computer.  The computer is connected directly to the cable (without box) line.  The computer is a HP 873n.

    I ran the TV setup in windows Media Center, but when I try to change the channel, the computer restarts.

    The absence of a digital tuner would cause the reset of the computer?  If so, what tuner would be compatible with the computer so I can install it?

    You need the Digital Terminal Adapter box that offers to Comcast. You should be
    able to get free of charge. See
     
    Friday, November 12, 2010, 03:16:04 + 0000, charipar wrote:
     
    >
    >
    > Great!  Thanks for all your help!  I really appreciate it!
    >
    > Update driver cured the problem.  I looked at your link, but it doesn't look like this tuner works with XP.  I'll get around.  I'm assuming that just because this computer has an analog tuner, it cannot get signal from comcast.  I just static on all channels (there no box, just connected directly to the coaxial cable.
     

    Barb Bowman

    http://www.digitalmediaphile.com

  • Media Center problem because it does not change the channel

    I recently changed my dish satellite Direct who changed the channel to 3 4.  My Media Center on my desk, I cannot change just the channel without going through the entire installation, which also requires a configuration for "Câble IR" which, for some reason, it does not.  Therefore, the only option I have given is 'back' or 'Cancel '.  'Back' has no effect except to find the IR cable, in vain.  'Cancel' I shot with no changes!  I'm stuck.  All I want to do is change the channel to receive the TV signal.  Help, please.

    Thank you, Ernest Smith

    Sorry, stupid.  All I had to do was change the channel with the remote control.

  • Windows Vista Media Center crashes when I change the channel

    Original title: Windows Vista Media Center

    Since the beginning of June whenever I try to change the channel on the TV tuner in Media Center it crashes. I tried to do a system restore but restore never worked on my count. Problem event name: APPCRASH. Application name: EHShell.exe I'm looking for suggestions that might solve this problem.

    1] updated TV Tuner card driver. Visit the manufacturer's Web site and download and install the latest driver.

    [2] delete the file mediaCenterDataStore.db. By default, this file is located in the following location:
    %SystemDrive%\ProgramData\Microsoft\eHome\mediaCenterDataStore.DB

    Delete: -.

    Start > run > type in %SYSTEMDRIVE%\ProgramData\Microsoft\eHome\mediaCenterDataStore.db > OK.

    Locate mediaCenterDataStore.db and right-click on it, select Delete.

    Restart the Media Center.

    S.Sengupta Media Center MVP

  • Change the channel for Virtual Wifi Miniport Adapter

    Hello!

    I was experiencing problems of interference when using the module of Virtual wifi miniport, and I would like to know if there is any way I can change the channel on the v-wifi is bradcasting?

    THX!

    Lee

    Well, I tried to find the latest driver for my card, I could find anything to the atheros website (what gives?).

    Win 7 told me I got the latest driver, but I wouldn't trust windows update, as they said that my ethernet card was up-to-date (see 7.04) and when I went on the Realtek site, driver to v.7.23...

    Anywho! I was not able to change the channel for the ad - hoc connection. I tried the connection with a PC and still cannot connect (so not a problem related to Mac).

    I don't know what is happening with the miniport module or the wireless card (I tried different settings in properties and the Advanced Options tab, as power management), but it just would not work. So I got this router, and everything works fine.

    This is!

  • Audio does not work in Windows 7 media center TV until I have change the channel!

    I have windows 7 ultimate with an analogue of PCTV PCI TV card 110. Whenever I start live TV in Windows media Center, there is no Audio data. But after changing the channel, the audio begins to work!

    Not a problem if used to watch TV. But the records get recorded without sound.

    Hello helloyul,

    Have you tried the utilities listed here?
    http://Windows.Microsoft.com/en-us/Windows-Vista/troubleshoot-audio-problems-in-Windows-Media-Center

    Let us know if it helps.

    Marilyn

  • Change the channel the program crashes

    Stick KWorld ATSC TV Tuner card

    Problem: when you press- or + to change the channel, after several changes, it HANGS (requires close the application).  New installation.  I installed the driver ArcSoft and SW accompanying from the CD.  Also for new installation of Win 7 Enterprise edition 64B.  Installation placed in the x 86 programs, so that it seems to be 32 b.  I have an ML110 HP containing a 4-core Xeon and graphics Nvidia FX1500 (latest driver) and Sound Blaster Audigy 24 b (latest driver).  What is a known compatibility issue?

    Problem is solved by uninstalling ArcSoft and using Windows Media Center.

    I'm also experimenting with responses, because I can't seem to get the tag "Mark as answer.

    http://answers.Microsoft.com/en-us/Windows/Forum/Windows_7-pictures/changing-the-channel-locks-up-the-program/c29f6a12-f2d9-4502-8DF5-1a9cf9046cee

  • Distance is not change the channel?

    I have associated my Sony Internet TV remote with my TV and it meets the test of volume, but the remote does not change channels... The guide also comes... Does anyone know how to fix this? I have a Samsung TV and DirecTV. Thank you.

    I just got my Internet tv. I have an HD box from comcast, vonnected to my TV with an hdmi cable. I don't know how to get the remote to change the channel. How can I synchronize the remote control in my comcast HD box?

  • A Message in a rectangular box "Messages Agent wants to use the 'Local products' kenchain. appearing on the screen and ask for Keychain password password.  This started after I changed the password of Apple resulting for the purchase of a new iPhone

    A Message in the box 1. "Message agent wants to use the 'Local products' kenchain. "is appearing on the screen and ask for Keychain password password.  This started after I changed the password of Apple resulting for the purchase of a new iPhone.

    My iPhone 5 has been damaged and the screen was not visible.  As a result, I couldn't open the iPhone.  I bought 5 s iPhone and when I got to connect with the iCloud

    I remember the answers to security questions.   The seller must change the password and enter new answers to security questions, I did.  This happened in Bangalore.  When I'm home in Ernakulam, Kochi (India), where I has the Air of Mac, Ipad and my wife had another iPhone and laptop computer Dell, these problems began to come up on the screen and blocks the screen.

    Four Messages are appearing: the first is on the top.

    Other messages are:

    2. ' cloudd wants to use the kenchain 'local products '. '

    appearing on the screen and ask for Keychain password password.

    3. ' com.apple.iCloudHelper.xpc wants to use the kenchain 'local products '. appearing on the screen and ask for Keychain password password.

    4. ' cloudpaired wants to use the kenchain 'local products '. ' is appearing on the screen and ask for Keychain password password.

    It of an upheaval and please suggest how to solve this problem

    Hello remy!

    I see that you are either prompted by iCloud Keychain with various alert messages.  I know it's important to have iCloud Keychain works correctly and I am pleased to offer you an article that should help you.  Please follow the instructions in the following support article:

    If your Mac keeps asking for the password in the keychain

    Thank you for using communities of Apple Support.

    See you soon!

  • Can I programmatically change the default property to create for all elements of the front panel?

    Can I programmatically change the default property to create for all elements of the front panel?

    I need to make the logout button, when click on, takes care of all the default values of my fron Panel.

    There is no way to programmatically call the functionality of an editor 'Use default' or 'Load Default'. To do it yourself, you will need to write your default values for each control explicitly in the diagram, when the user press the logout button.

Maybe you are looking for