Insert byte[] into postgres text-field

Hi,
i made some tries on using postgresql and jdbc, i noticed that
for some reason the postgres jdbc.driver does not convert
text from the db correct to UNICODE. The db is in ISO-8859-1.
So, i tried to write a workaround to this and was successfull
for reading data. The code is this:
try {
    String  sOrt   = null;
    InputStreamReader isString;
    BufferedReader bisString;
    ResultSet result =
        stmt.executeQuery( "select * from adresse.ort" );
    while( result.next() ) {
        isString = new InputStreamReader(
                            result.getBinaryStream( "ort" ),
                            "ISO-8859-1" );
        bisString = new BufferedReader( isString );
        sOrt = bisString.readLine();
...This works fine. Now i also wanted to but a correctly convertet
String in the db.
And i tried so:
try {
    String sOrt = "solal�";    // note the special german char �
    byte[] sOrt_ba = sOrt.getBytes( "ISO-8859-1" );
    pstmt = con.prepareStatement( "insert into adresse.ort " +
                                  "(ort, vorwahl_o, id_land) " +
                                  " values " +
                                  "(?, '00000', 1)" );
    pstmt.setBytes( 1, sOrt_ba );
    int sRows;
    sRows = pstmt.executeUpdate();
}but this sets not the correct character for the special char �
but instead puts the byte-value \366 into the db.
My question is as simple as the answer might be complex, what am
i doing wrong, and how can i accomplish this.

i found a solution for me, its not clean (to be sure its very ugly) but it works for the moment, if anyone has a better idea please tell. I will make the
following.
create a small plpgsql function like this.
CREATE FUNCTION jdbc_clean(text) RETURNS text AS'
    DECLARE
        ret text;
    BEGIN
        SELECT INTO ret replace($1, ''\\\\344'', ''�'');
        SELECT INTO ret replace(ret, ''\\\\366'', ''�'');
        SELECT INTO ret replace(ret, ''\\\\374'', ''�'');
        SELECT INTO ret replace(ret, ''\\\\337'', ''�'');
        RETURN ret;
    END;
' LANGUAGE 'plpgsql'and call this in my Java-method for every String i inserted or
updated in a seperate update query.
I have not written it for now, but i guess this will be working.

Similar Messages

  • Is there a way to import data from a specific text field in a PDF form directly into a text field in a different PDF?

    I know you can import form data from an .fdf file. Is there a way to import a specific value from that .fdf file into a text field in a separate pdf form?

    So I want the FDF to export every time the user saves or closes the PDF. Then I want the import to happen every time the user opens the PDF. That being said, this all has to work with Adobe Reader. If this is possible in anyway, I'd manage this would require some time of script. Any thoughts?

  • I bought versions for iPad and for MacBook. At synchronization of documents on MacBook all smilies from the Emoji keyboard disappeared. It is impossible to insert them into the text manually. Smiles of Emoji are supported by the program for Mac? Help to s

    I bought versions for iPad and for MacBook. At synchronization of documents on MacBook all smilies from the Emoji keyboard disappeared. It is impossible to insert them into the text manually.
    Smiles of Emoji are supported by the program for Mac?
    Help to solve a problem, please.

    Same thing happened to me with my peruvian credit card in the peruvian app store, I want to buy an app, but it says that my credit card is "not supported in the Peruvian app store"

  • Split imported XML data into multiple text fields

    I should first describe my final project because it is very possible that I am going about this entirely wrong!
    I am trying to create an interactive PDF file which is the floor plan of our office, when you mouse over the office spaces it would popup the info for the person in that office, in fact when you click on the office space it would show additional info like computer MAC and jack numbers
    I placed the floor plan as a layer and them created a second layer with no fill/no stroke rectangles over the offices and made them buttons (office01, office02)
    I then made text fields with the info for the people, one for regular info and one for extra info (office01-data, office01-Xdata) I made these text fields buttons as well and had them "hidden until triggered"
    These info fields are all on top of one another, as in the are all the same size and in teh same location
    Then I went to the office buttons and created events "On Roll Over" "Show/Hide Buttons and Forms" and changed the visibility of the corresponding info button.
    This works like a charm!
    I hope I am clear up to this point.... my problem now is I would like to import this data both regular and extra from an excel spreadsheet or an XML file.
    That way when we get new staff or people move offices or whatever I can update the spreadsheet or XML file, rerun my InDesign file and create a new interactive PDF
    I have created the XML file
    <staffMap>
         <staff>
              <name>John Doe</name>
              <computerName<gfth56df</computerName>
              <phoneMAC>00:08:00:AB:CD:EF</phoneMAC>
         </staff>
    <staff>
              <name>John Smith</name>
              <computerName<gfth06cb</computerName>
              <phoneMAC>00:08:00:11:22:33</phoneMAC>
         </staff>
    </staffMap>
    Created a new InDesign document
    Imported the XML and placed it in a text field
    saved as a template and closed it
    Reopen and import the XML data again... and it brings it all into the text field... wonderful and useful but not what I need.
    Is it possible to import the XML data into separate test fields, or into some other separate field that I can make into a button and show/hide?
    I may end up just entering all the data directly into InDesign as I know this will work, it just does not seem like the right way to do it.
    Thanking you all in advance 

    I am still looking to get some help with this.
    I would love to know if it is not possible or any ideas at all

  • Inserting in-line variable into a text field

    Hello,
    I want to add a variable within a text field (dymanic value within a sentence). Basically, I want the form to display something like the following:
    "The person named <person name> is an employee of the company"
    The only way I could do this so far is by creating three elements on the form: the first is a text element that contains "The person named", the seond is a text field element with no label that contains the "<person name>" variable, and the third is another text element that contains "is an employee of the company."
    I don't really like this approach as if the name of the employee is too long, it might get cut off. If it was too short, there will be a lot of extra space between the name and the rest of the sentence.
    Another solution is to pass a string variable with the complete text (I'll have to build the string before calling the form). Similarly, I can pass an internal table with the text. I don't think either of these two solutions is ideal as LifeCycle designer should provide an easier way to do so (just like in SmartForms).

    Hi Abdullah Azzouni ,
    This is possible to add a dynamic text between the static text in Adobe form.
    For that suppose you have a Static Text field TEXT1 on your layout. Just right click over the text inside this field and on the pop-up choose "Floating Text". It will create a textfield in your subform. Now bind this newly created textfield to the field in the datasource say PERNR in your case.
    It will appear like: "The person named is an employee of the company"
    In this way you can add a dynamic text in between your static text in a text field.
    Regards,
    Vaibhav

  • Insert a Value into a Text Field

    Hello,
    I have a prbmel. I have a Text Field Item on my page. Now I want that it loads automatically, so before de header is loaded, a value out of a tabel in it. Therefore I created an PL/SLQ statement
    declare
    function get_current_id return number
    is
    ret number;
    begin
    for i in (select my_column idt from my_tabel)
    loop
    ret:= i.idt;
    end loop;
    return ret;
    end;
    begin
    :P1_ID:=get_current_id;
    end;
    I know taht it is working becasue I have tested it in the SQL Command line but in the Page the Value isn't displyed. Can someone tell me why?

    Hi
    I think you are trying to populate ID value (primary key) with the last value of your table? Is that you are trying? If it's NUMBER column you better try to use MAX function..
    Since you want default value for only one item, Edit item P1_ID -> go to Default value section
    Select default type as SQL and put following SQL
    SELECT MAX(my_column) FROM my_table;So on page load, P1_ID will get populated with MAX value of my_column from my_table
    Cheers,
    Hari

  • Inserting data into a CLOB Field

    I am trying to insert a 100,000+ byte string into a CLOB field in Oracle, but I'm getting a "string literal too long" error. I am using Visual Basic and ADO to try to accomplish this. My insert statement is:
    sql = "INSERT INTO IMAGE_VERSION " & _
    "(field1, field2, field3)" & _
    "VALUES('" & strNm & "', '" & strDt & "', '" & strData & "')"
    Field 3 is defined as a CLOB in the database. From what I understand, the CLOB can hold massive amounts of data.
    Can anyone lend a hand?

    Re: OTN Downloads

  • Query a view w/data entered into a text field populated by 2 table fields

    Hello, Looking for advise!!! I have a tabular canvas thats datablock uses a view to populate. In this canvas I have a text field that has been populated with first_name || ' ' || last_name in the database node of the property pallate column name. The text field is not in the table or view. I have created it in the data block and make it a database item. However, I would like to have the user push a search button to go into ENTER_QUERY mode then the user would enter the criteria to search on in this text field. The user would then push button to EXECUTE_QUERY. The result is I retrieve all records. I want any search criteria entered into this field to be used against the last_name field to retrieve any records equal to the search criteria entered, for example A%. Does anyone know if this is possible?

    Hi!
    You have to use PRE-QUERY trigger to compose the search criteria. Below I put an example of it. You have to have at least one item in the block wich is true database item (e.g. it has to exist in table or view on which your block is based). In the following example EMP_DESC is your non-database search item and EMP_ID is the database one.
    Declare
    Dummy VARCHAR2 (2000);
    begin
    if :EMP.EMP_DESC IS NOT NULL and :EMP.EMP_ID IS NULL
    then
    Dummy := '#IN (SELECT emp_id FROM Employees WHERE Upper (emp_first_name)||'' ''||Upper (emp_sec_name) LIKE Upper (''%'||:EMP.EMP_DESC||'%''))';
    Copy (Dummy, 'EMP.EMP_ID');
    end if;
    end;
    Thats it. Note the # sign in the first position of the Dummy assignment. This is required by forms to glue your search criteria and block's where clause. You may analize LAST_QUERY property of your block in order to understand how this work. Remember also to set the QUERY_LENGTH property of the EMP_DESC item to the value that could contain the whole Dummy string (otherwise it will give you an error and cut the mar the query).
    Hope this helps.
    Sergey.
    P.S. And set your EMP_DESC database item property to NO.

  • Insert timestamp into a Date field.

    Hi anyone knows if I insert a timestamp into a date field, will it sort according to the date field if I use an sql statement to sort the data?

    Your question is quite unclear, it sounds like you have two questions:
    1. Can I insert a timestamp into a date field (in the database?)?
    2. Can I sort my sql statement using the date field?
    Is this what you are asking? If not, please clarify.

  • Putting variable text into dynamic text field

    How can I make var text input into a dynamic text field that
    appears within another timeline (movieclip) on a different
    frame?

    How can I make var text input into a dynamic text field that
    appears within another timeline (movieclip) on a different
    frame?

  • Put PHP Content into Dynamic Text Field

    How do I put the contents of a php document into a dynamic
    text field in a Flash document? Thanks.
    G

    Do you mean an html document generated from a PHP script?
    Do you mean the source of a PHP script?
    Probably you mean you want to format a page such as a PHP
    script would do.
    That is done either manually inside a Flash movie or
    dynamically via
    Actionscripting. Then you only send data back and forth
    between PHP and
    Flash using either the LoadVars or the XML Actionscript
    classes. You can use
    HTML inside of Flash TextField objects but again that will be
    data sent from
    the PHP server script.
    Here are some basic examples I use in Flash seminars you can
    look at:
    http://www.hosfordusa.com/ClickSystems/courses/flash/examples/LoadVars/LoadVarsEx01.php
    http://www.hosfordusa.com/ClickSystems/courses/flash/examples/LoadVars/Ex02/LoadVarsEx02.p hp
    http://www.hosfordusa.com/ClickSystems/courses/flash/examples/GenerateFlashObjectsFromPHP/ Ex01/GenerateFlashObjectsFromPHPEx01_Doc.php
    http://www.hosfordusa.com/ClickSystems/courses/flash/examples/XMLPHP/EX01/XMLPHPEchoEx01_D oc.php
    You also want to look at the docs for LoadVars and XML
    sendAndLoad methods:
    XML
    http://livedocs.macromedia.com/flash/8/main/00002879.html
    LoadVars
    http://livedocs.macromedia.com/flash/8/main/00002336.html
    Lon Hosford
    www.lonhosford.com
    May many happy bits flow your way!
    "gena.wenli" <[email protected]> wrote in
    message
    news:e5g6av$lpv$[email protected]..
    How do I put the contents of a php document into a dynamic
    text field in a
    Flash document? Thanks.
    G

  • Forcing carriage returns when writing into a text field in director 7

    I am trying to put together a data table in a text field in
    director 7. I have a 4 variables that contain random numbers. I
    would like my data table to appear in the following format:
    P1 xxx atm
    V1 xxx mL
    P2 xxx atm
    V2 xxx mL
    I was trying to do it into a single text field by
    concatenating the text string for the variable name, the variable,
    and also the variables containing the units. Unfortunately, the
    different units are all different lengths, so I keep getting word
    wrap issues. Is there anything I can do to just tell it to start a
    new line?
    My workaround was to put each line into a different field,
    but .....
    Any help would be appreciated.
    BobR

    This is actually fairly simple when working with numbers,
    because numbers
    (in most fonts) are fixed-width. X number of digits will take
    up Y amount
    of space, regardless of what those digits are. Thus, if you
    figure out the
    maximum number of digits that will fit into your column, you
    can count the
    digits of your random number to see if it'll fit, and then
    add RETURNs in it
    if it won't. Another thing you can do if it fits your style
    is pad the
    numbers with leading 0's. _'s are also usually the same width
    as numbers.
    At any rate, it's a little hard to help if we don't have a
    good idea of what
    kind of data you're trying to display - what's the range of
    numbers, for
    example? If you know about how many digits you'll have in
    your longest
    numbers, you should be able to tailor your text member to be
    able to fit
    that many digits without wrapping, just by typing in 12345678
    or however
    many digits you need and stretching things to fit that. It
    gets a good deal
    trickier with letters, unfortunately - "woman" takes up more
    space than
    "illicit" despite containing 2 fewer letters. There's ways of
    dealing with
    that, but they're not easy...

  • Inserting Leads into a Text File?

    Hello there, I am wondering if there is a way to insert leads
    into a .txt file once a form is submitted?
    If so how would this be achieved. I know you can do this with
    PHP as I have done it before.
    Thanks
    Derek Bess

    > insert leads into a .txt file
    There are plenty of file tags and functions available. But
    what do you mean by "leads"?
    http://livedocs.adobe.com/coldfusion/8/htmldocs/functions-pt0_20.html#1100017

  • How to get the field texts from abap dictionary into screen Text fields

    Hi SapAll.
    here i have got to modify one zscreen by adding 1 more field,when i added one field in teh screen by just writng the code in program as SELECT-OPTIONS ilart FOR CAUFVD-ILART.
    but iam unable to get the field text for the text field from teh table CAUFVD.
    CAN ANY BODY HELP ME IN THIS.
    regards.
    varma

    Hi Varma,
    Even if you want to personalise the Text also you can do without checking the DICTREF checkbox. Dirctly you can give the text in the Text elements by using the Menu GOTO -> Text Elemetns -> Selection Texts.
    Regards
    Thiru

  • Multiple fields from a rowset into 1 text field

    Is there anyway to take multiple rows from a rowset. And append them together in one text field?
    example
    rowsetloc/county = 33
    rowsetloc/permit = 214
    then in my text box on my form have 33-214.
    I'm using BC4J to develop my applications.
    null

    John,
    You can do this at several BC4J "levels"; I would suggest modifying your view to contain this attribute.
    Modify the SELECT statement of your view to contain something like
    "SELECT
    TheTable.COUNTY,
    TheTable.PERMIT
    TheTable.COUNTY &#0124; &#0124; '-' &#0124; &#0124; TheTable.PERMIT AS SPECIALNUMBER
    FROM THETABLE TheTable"
    So, you are basically creating an attribute by concating two columns from the database.
    Then, you might be able to remove the other attributes, County and Permit. You must provide some logic to provide editability and validation of this new attribute, SpecialNumber. This could be a bit of work...
    Joe

Maybe you are looking for

  • Help with Layout

    I've got a simple layout but I need to get it looking more like this picture: http://members.lycos.nl/ghanswebsite/Layout.JPG Now I got a simple GridBag. I tried a few other layouts but they got me errors so until now I evaded them .. :-(. // Fig. 12

  • Songs wont play. keeps asking for authorisation.

    Have windows Vista. Recently purchased Alt J album from itunes store. Three of the tracks wont play. It keeps asking for authorisation when trying to play them. Have deauthorised and reauthorised a number of times and they still wont play. I have tur

  • Explain me SOAP - RFC scenario?

    Can any one brifely explain me about the SOAP sender configuration settings (i.e like after we create the wsdl structure how to use it )

  • Some quesionts about message mapping

    becase I need use some pics to explain my question, so I post the question to my googlepage. <a href="http://wanghui1225.googlepages.com/xi_question_1">http://wanghui1225.googlepages.com/xi_question_1</a> Regards, Hui Message was edited by: Wang Hui

  • Make VC3 come up as an actual device driver

    With all the live streaming sites these days, this would be incredible to work with via a web application. But to simplify this all I would need is for VC to come up in the list of Sound, Video, and Gaming Controllers. Instead I'm barley trying to fi