Conversion of  String to Binary

Hi,
I would like to know if there are any API's to convert a given string to the binary. Also If there is any method to convert String(ex "abc")to Integer please let me know.
Thanks,
Anuja

use this code :
class Empty {
    public static void main(String args[])
        String s = "Hello"; // lets say string is hello
    char[] chars= new char[s.length()];
    int[] ints = new int[chars.length];
    s.getChars(0,s.length(),chars,0);
    for(int i=0;i<chars.length;i++) {
        ints=(int)chars[i];
System.out.println(chars[i]+" = "+ints[i]);
it works
i used it in sun one studio 4 update 1

Similar Messages

  • Sporadically getting error "string or binary data would be truncated" in SQL server 2008 while inserting in a Table Type object

    I am facing a strange SQL exception:-
    The code flow is like this:
    .Net 4.0 --> Entity Framework --> SQL 2008 ( StoredProc --> Function {Exception})
    In the SQL Table-Valued Function, I am selecting a column (nvarchar(50)) from an existing table and (after some filtration using inner joins and where clauses) inserting the values in a Table Type Object having a column (nvarchar(50))
    This flow was working fine in SQL 2008 but now all of sudden the Insert into @TableType is throwing  "string or binary data would be truncated"  exception. 
    Insert Into @ObjTableType
    Select * From dbo.Table
    The max length of data in the source column is 24 but even then the insert statement into nvarchar temp column is failing.
    Moreover, the same issue started coming up few weeks back and I was unable to find the root cause, but back then it started working properly after few hours
    (issue reported at 10 AM EST and was automatically resolved post 8 PM EST). No refresh activity was performed on the database.
    This time however the issue is still coming up (even after 2 days) but is not coming up in every scenario. The data set, for which the error is thrown, is valid and every value in the function is fetched from existing tables. 
    Due to its sporadic nature, I am unable to recreate it now :( , but still unable to determine why it started coming up or how can i prevent such things to happen again.
    It is difficult to even explain the weirdness of this bug but any help or guidance in finding the root cause will be very helpful.
    I also Tried by using nvarchar(max) in the table type object but it didn't work.
    Here is a code similar to the function which I am using:
    BEGIN
    TRAN
    DECLARE @PID
    int = 483
    DECLARE @retExcludables
    TABLE
        PID
    int NOT
    NULL,
        ENumber
    nvarchar(50)
    NOT NULL,
        CNumber
    nvarchar(50)
    NOT NULL,
        AId
    uniqueidentifier NOT
    NULL
    declare @PSCount int;
    select @PSCount =
    count('x')
    from tblProjSur ps
    where ps.PID
    = @PID;
    if (@PSCount = 0)
    begin
    return;
    end;
    declare @ExcludableTempValue table (
            PID
    int,
            ENumber
    nvarchar(max),
            CNumber
    nvarchar(max),
            AId
    uniqueidentifier,
            SIds
    int,
            SCSymb
    nvarchar(10),
            SurCSymb
    nvarchar(10)
    with SurCSymbs as (
    select ps.PID,
                   ps.SIds,              
                   csl.CSymb
    from tblProjSur ps
                right
    outer join tblProjSurCSymb pscs
    on pscs.tblProjSurId
    = ps.tblProjSurId
    inner join CSymbLookup csl
    on csl.CSymbId
    = pscs.CSymbId 
    where ps.PID
    = @PID
        AssignedValues
    as (
    select psr.PID,
                   psr.ENumber,
                   psr.CNumber,
                   psmd.MetaDataValue
    as ClaimSymbol,
                   psau.UserId
    as AId,
                   psus.SIds
    from PSRow psr
    inner join PSMetadata psmd
    on psmd.PSRowId
    = psr.SampleRowId
    inner join MetaDataLookup mdl
    on mdl.MetaDataId
    = psmd.MetaDataId
    inner join PSAUser psau
    on psau.PSRowId
    = psr.SampleRowId
                inner
    join PSUserSur psus
    on psus.SampleAssignedUserId
    = psau.ProjectSampleUserId
    where psr.PID
    = @PID
    and mdl.MetaDataCommonName
    = 'CorrectValue'
    and psus.SIds
    in (select
    distinct SIds from SurCSymbs)         
        FullDetails
    as (
    select asurv.PID,
    Convert(NVarchar(50),asurv.ENumber)
    as ENumber,
    Convert(NVarchar(50),asurv.CNumber)
    as CNumber,
                   asurv.AId,
                   asurv.SIds,
                   asurv.CSymb
    as SCSymb,
                   scs.CSymb
    as SurCSymb
    from AssignedValues asurv
    left outer
    join SurCSymbs scs
    on    scs.PID
    = asurv.PID
    and scs.SIds
    = asurv.SIds
    and scs.CSymb
    = asurv.CSymb
    --Error is thrown at this statement
    insert into @ExcludableTempValue
    select *
    from FullDetails;
    with SurHavingSym as (   
    select distinct est.PID,
                            est.ENumber,
                            est.CNumber,
                            est.AId
    from @ExcludableTempValue est
    where est.SurCSymb
    is not
    null
    delete @ExcludableTempValue
    from @ExcludableTempValue est
    inner join SurHavingSym shs
    on    shs.PID
    = est.PID
    and shs.ENumber
    = est.ENumber
    and shs.CNumber
    = est.CNumber
    and shs.AId
    = est.AId;
    insert @retExcludables(PID, ENumber, CNumber, AId)
    select distinct est.PID,
    Convert(nvarchar(50),est.ENumber)
    ENumber,
    Convert(nvarchar(50),est.CNumber)
    CNumber,
                            est.AId      
    from @ExcludableTempValue est 
    RETURN
    ROLLBACK
    TRAN
    I have tried by converting the columns and also validated the input data set for any white spaces or special characters.
    For the same input data, it was working fine till yesterday but suddenly it started throwing the exception.

    Remember, the CTE isn't executing the SQL exactly in the order you read it as a human (don't get too picky about that statement, it's at least partly true enough to say it's partly true), nor are the line numbers or error messages easy to read: a mismatch
    in any of the joins along the way leading up to your insert could be the cause too.  I would suggest posting the table definition/DDL for:
    - PSMetadata, in particular PSRowID, but just post it all
    - tblProjectSur, in particularcolumns CSymbID and TblProjSurSurID
    - cSymbLookup, in particular column CSymbID
    - PSRow, in particular columns SampleRowID, PID,
    - PSAuser and PSUserSur, in particualr all the USERID and RowID columns
    - SurCSymbs, in particular colum SIDs
    Also, a diagnostic query along these lines, repeat for each of your tables, each of the columns used in joins leading up to your insert:
    Select count(asurv.sid) as count all
    , count(case when asurv.sid between 0 and 9999999999 then 1 else null end) as ctIsaNumber
    from SurvCsymb
    The sporadic nature would imply that the optimizer usually chooses one path to the data, but sometimes others, and the fact that it occurs during the insert could be irrelevant, any of the preceding joins could be the cause, not the data targeted to be inserted.

  • Conversion from string "20041023 " to type 'Date' is not valid.

    Hi ,
       I have a table with one of the column(EmpHiredate) datatype is char(10). It has value like "20141023". I need to display this value as date format(dd/mm/yyyy) in report. 
    Following methods i tried in textbox expression but no luck.
    =Format(Fields!EmpHireDate.Value,"dd/MM/yyyy")
    =Cdate(Fields!EmpHireDate.Value)
    Error:
    [rsRuntimeErrorInExpression] The Value expression for the textrun ‘EmpHireDate.Paragraphs[0].TextRuns[0]’ contains an error: Conversion from string "20041023  " to type 'Date' is not valid.
    Is it possible to convert string to date using SSRS textbox expression ? Can anyone help me with the solution.
    Thanks,
    Kittu

    Hi Jmcmullen,
         Found one more issue on the same. I have one value like "00000000" for the column(EmpHiredate)
    , when i use above expression values(ex:"20141023")
    are displaying in dd/MM/yyyy format in report except value like "00000000" and giving following error:
    [rsRuntimeErrorInExpression] The Value expression for the textrun ‘EmpHireDate.Paragraphs[0].TextRuns[0]’ contains an error: Conversion from string "0000/00/00" to type 'Date' is not valid.
    Even i tried to pass its original value("00000000") as below but no luck.
    =IIF(Fields!EmpHireDate.Value = "00000000","00000000",Format(CDATE(MID(Fields!EmpHireDate.Value,1,4) + "/" + MID(Fields!EmpHireDate.Value,5,2) + "/" + MID(Fields!EmpHireDate.Value,7,2)),"dd/MM/yyyy"))
    Also tried this:
    =IIF(Fields!EmpHireDate.Value = "00000000","2000/10/21",Format(CDATE(MID(Fields!EmpHireDate.Value,1,4) + "/" + MID(Fields!EmpHireDate.Value,5,2) + "/" + MID(Fields!EmpHireDate.Value,7,2)),"dd/MM/yyyy"))
    Please Suggest. 
    Thanks ,
    Kittu

  • Problem with conversion of strings like THISStr - this_str capitalization

    Problem with conversion of strings like. THISStr -> this_str
    Can anybody pass on the reverse code. I have one, but its faulty.
    public static String convertFromPolycaps(String str) {
              Pattern pattern = Pattern.compile("\\p{Upper}+");
              Matcher matcher = pattern.matcher(str);
              StringBuffer result = new StringBuffer();
              // We do manual replacement so we can change case
              boolean notFirst = false;
              int grpP = 0, grpA = 0;
              String last = "";
              String now = "";
              while (matcher.find()) {
                   grpA = matcher.end();
                   if (notFirst) {
                        now = matcher.group().substring(0).toLowerCase();
                        if (grpA - grpP > 1) {
                             matcher.appendReplacement(result, now);
                             result =
                                  new StringBuffer(
                                       result.substring(0, (result.length() - 1))
                                            + "_"
                                            + result.substring(result.length() - 1));
                        } else {
                             matcher.appendReplacement(result, "_" + now);
                   } else {
                        matcher.appendReplacement(result, matcher.group().substring(0).toLowerCase());
                        notFirst = true;
                   grpP = matcher.end();
                   ////index++;
                   last = now;
              matcher.appendTail(result);
              System.err.println(str + " : " + result.toString());
              return result.toString();
         }succesfully converts :
    AccountNmnc : account_nmnc
    CustNameJ : cust_name_j
    Resume : resume
    BeneBrCode : bene_br_code
    ApprovedPerson : approved_person
    but fails for:
    GLCode : glcode
    VISHALErrCode : vishalerr_code
    GHASUNNAcNo : ghasunnac_no

    Can anybody pass on the reverse code. I have one, but
    its faulty.Post it, I'm sure we can fix it...

  • Conversion of string into XML object

    Hi
    I am having some problems with conversion of string (containing XML data) into Flex XML object and binding it later to UI elements to output/maintain this data.
    Binding of XML structure to UI elements works perfectly fine if I will do following:
    1)      Hardcode XML object within Flex file
    2)      Read xml file from repository (xml file inside the Flex project)
    3)      Use HTTP request to retrieve XML data
    Unfortunately none of the above scenarios suits my solution.
    I am developing a prototype application for processing Flex forms inside SAP system. I have decided to make data bindings using XML structure stored in Data Base. When rendering form inside web browser based application I am retrieving corresponding XML schema (empty for new forms and populated for saved forms) and pass it to Flex form as a string type import parameter. Data is being passed correctly (I can display it on TextArea control for instance) but after conversion to XML and binding to DataGrid I am not getting any results.
    I am converting string (containing XML) to XML object in following way:
    Private var xml_obj:XML = new XML(string_xml );
    I am catching any potential errors but conversion is going well. After conversion I am not getting any results after binding it to DataGrid control and I am not able to access any of the nodes using AS code either. At the same time variable xml_obj is not empty (not null).
    Any help would be much appreciated.
    Regards
    Michael

    David
    First of all sorry for not stating it clearly but I am using Flex 3 for this development (at the moment it is the only choice when embedding Flex objects inside SAP applications).
    You must have missed the bit where I am describing how this XML data finds its way inside Flex. I am passing it to Flex as String type parameter during rendering (directly from DB where it is stored).
    Now, following code works perfect (XML is embedded inside Flex project):
                    <mx:XML id="form_data" source="../assets/example_xml_data.xml"/>
                    <mx:Script>
                                    <![CDATA[
                                                    import mx.collections.XMLListCollection;
                                                    import mx.controls.Alert;
                                                    [Bindable]
                                                    public var XML_list:XMLListCollection;
                                                    private function setParameters():void
                                                                   XML_list = new XMLListCollection(form_data.*);             
                                    ]]>
                    </mx:Script>
                    <mx:DataGrid id="myDataGrid" dataProvider="{XML_list}">
                                    <mx:columns>
                                                    <mx:DataGridColumn dataField="COMMON" headerText="Popular name"/>
                                                    <mx:DataGridColumn dataField="BOTANICAL" headerText="Botanical name"/>
                                                    <mx:DataGridColumn dataField="ZONE" headerText="Zone"/>
                                                    <mx:DataGridColumn dataField="LIGHT" headerText="Light"/>                                                                                                                                               
                                                    <mx:DataGridColumn dataField="PRICE" headerText="Price"/>                                               
                                                    <mx:DataGridColumn dataField="AVAILABILITY" headerText="Availability"/>                                    
                                    </mx:columns>               
                    </mx:DataGrid>
    But following code does not work (XML passed to Flex form as String input parameter):
    import sap.FlashIsland;
    import mx.controls.Alert;
    import mx.collections.XMLListCollection;
    [Bindable]
    public var xml_data:String;
    private var form_data:XML;
    [Bindable]
    private var XML_list:XMLListCollection;
    private function initApp():void
                    FlashIsland.register(this);
    private function setParameters():void
                    try
                                    form_data=new XML(xml_data);
                    catch (error:Error)
                                    Alert.show(error.toString());
                      XML_list = new XMLListCollection(form_data.*);           
    XML string does find its way inside Flex form. I can display content of variable xml_data in TextArea and all looks fine. Conversion to XML (variable form_data) goes well (no error)
    Please helpJ
    Regards
    Michael

  • "Conversion to String failed"  When attempting to call rs.getString()

    Hello All,
    I'm getting a "Conversion to String failed" exception being thrown from oracle jdbc when I attempting to call the rs.getString(1) method on a column type of DATE.
    During investigations we've found the following:
    1. The query is fine, and is performing a "select * from table".
    2. I see this problem when using 9i database (v 9.2.0.7) with 9i jdbc drivers (v9.2.0.7).
    3. Strangely enough, if I use 10g jdbc drivers with the 9i database this problem goes away, and naturally I don't see this problem at all using a 10g driver working against a 10g database.
    4. Grabbing the DATE value using the getDate() instead of getString() API works just fine in 9i.
    5. The 9i rs.getString() API call will work with some date values in the database and not with others.
    6. The data placed into the DATE column in question could have been placed there using different driver type from the 9i.
    So, the 9i getString() API seems to be a problem.
    At this point, based upon points 5 and 6 above, I'm thinking there is a bug in the oracle 9i jdbc drivers that is unable to convert DATE type data using the getString() API if the data was initially placed into the database using a different driver type. But, this would mean that the format of the data in the database would be different depending upon the means of getting the data there in the first place (which doesn't make much sense).
    Here is the pertinent Stack Trace:
    java.sql.SQLException: Conversion to String failed
    at oracle.sql.Datum.stringValue(Datum.java:173)
    at oracle.jdbc.driver.ScrollableResultSet.getString(ScrollableResultSet.java:684)
    at oracle.jdbc.driver.OracleResultSet.getString(OracleResultSet.java:1549)
    at com.revenuesolutionsinc.dali.sql.DALResultSet.getString(DALResultSet.java:325)
    Any help on this matter would be greatly appreciated.
    Thanks,
    Doug Newcomb

    Doug,
    Pardon me for stating the obvious, but is there a
    reason why you cannot use method "getDate()" instead
    of method "getString()"?
    For your information, you can report bugs via the
    MetaLink
    Web site.
    Good Luck,
    Avi.Thanks for the reply Avi,
    The main reason is that we've got mountains of code that would need to be refactored. Also, the getString() method worked fine for over a year.
    So we are looking towards finding out why this is happening before making the decision to refactor.
    I will be placing a TAR with Oracle on Monday, but I thought I'd try to find out if anyone else has run into a similar problem.

  • Regional settings impact JavaScript Number conversion to String in applet

    Environment:
    XP, IE6 and IE7, JDK 1.6.0_13,1.6.0_10,1.6.0_7, Apache
    Hi,
    We recently converted our application from the MS JVM to Sun JVM 1.6 and have since had numerous problems with a user's regional setting impacting the application's behaviour.
    The application is using an applet, passing JavaScript Number values to an Applet where the input argument in the Java function is declared as a String.
    We have users with various regional settings, most don't impact the application, but we have found problems when the regional settings are set to "French (France)" or "German (Germany)".
    With "French (France)" JavaScript Number values >=10000000 get truncated to a Java String value of just the first character.e.g. 10000000 is converted to "1", 200000000 is converted to "2".
    With "German (Germany)" a trailing "0" is added to the converted String, and for values >=10000000 we get the String value with an additional 6 "0"s and then 2 additional "0"s as the input Number value is increments by each power of 10.
    A simple example follows.
    Any help understanding why this is happening and any coding solution would be appreciated.
    The default number format for the various regional settings seems to be impacting the implicit conversion to String in LiveConnect.
    We can re-code to convert the Number value to a String in the JavaScript before calling the applet, but this involves significant re-coding of the application.
    We also have a workaround to verify that navigator.userLanguage returns one of the list of supported languages and exit the application if the language is unsupported.
    Thanks
    Rob
    Example output for test:
    OK
    English (United States)
    Regional Settings Number format sample: 123,456,789.00
    lang=en-us,javascript Number=1,Applet Java String value =(1)
    lang=en-us,javascript Number=11,Applet Java String value =(11)
    lang=en-us,javascript Number=111,Applet Java String value =(111)
    lang=en-us,javascript Number=1111,Applet Java String value =(1111)
    lang=en-us,javascript Number=11111,Applet Java String value =(11111)
    lang=en-us,javascript Number=111111,Applet Java String value =(111111)
    lang=en-us,javascript Number=1111111,Applet Java String value =(1111111)
    lang=en-us,javascript Number=11111111,Applet Java String value =(11111111)
    lang=en-us,javascript Number=111111111,Applet Java String value =(111111111)
    lang=en-us,javascript Number=1111111111,Applet Java String value =(1111111111)
    lang=en-us,javascript Number=11111111111,Applet Java String value =(11111111111)
    NOT OK >=10000000
    French (France)
    Regional Settings Number format sample: 123 456 789,00
    lang=fr,javascript Number=1,Applet Java String value =(1)
    lang=fr,javascript Number=11,Applet Java String value =(11)
    lang=fr,javascript Number=111,Applet Java String value =(111)
    lang=fr,javascript Number=1111,Applet Java String value =(1111)
    lang=fr,javascript Number=11111,Applet Java String value =(11111)
    lang=fr,javascript Number=111111,Applet Java String value =(111111)
    lang=fr,javascript Number=1111111,Applet Java String value =(1111111)
    lang=fr,javascript Number=11111111,Applet Java String value =(1)
    lang=fr,javascript Number=111111111,Applet Java String value =(1)
    lang=fr,javascript Number=1111111111,Applet Java String value =(1)
    lang=fr,javascript Number=11111111111,Applet Java String value =(1)
    NOT OK
    German (Germany)
    Regional Settings Number format sample: 123.456.789,00
    lang=de,javascript Number=1,Applet Java String value =(10)
    lang=de,javascript Number=11,Applet Java String value =(110)
    lang=de,javascript Number=111,Applet Java String value =(1110)
    lang=de,javascript Number=1111,Applet Java String value =(11110)
    lang=de,javascript Number=11111,Applet Java String value =(111110)
    lang=de,javascript Number=111111,Applet Java String value =(1111110)
    lang=de,javascript Number=1111111,Applet Java String value =(11111110)
    lang=de,javascript Number=11111111,Applet Java String value =(111111110000000)
    lang=de,javascript Number=111111111,Applet Java String value =(11111111100000000)
    lang=de,javascript Number=1111111111,Applet Java String value =(1111111111000000000)
    lang=de,javascript Number=11111111111,Applet Java String value =(1.1111111111E20)
    Example code:
    Test1.java
    import java.applet.Applet;
    public class Test1 extends Applet {
    public void init() {
    public String stringTest(String str) {
    String out = "Applet Java String value =(" + str + ")";
    return(out);
    index.html
    <html>
    <body>
    <APPLET CODE="Test1.class" NAME="test1" WIDTH="0" HEIGHT="0">
    <PARAM NAME="scriptable" Number="true">
    </APPLET>
    <script type="text/javascript">
    var x;
    document.write("<BR>")
    x = Number("1");
    document.write("lang="+navigator.userLanguage +",javascript Number=" x "," + document.test1.stringTest(x)+"<BR>");
    document.write("<BR>copy/paste the above 2 lines of code, adding an additional '1'<BR>");
    </script>
    </body>
    </html>
    </html>

    I have found a workaround by setting the locale in the applet to a locale that does perform implicit Number to String conversion correctly.
    e.g.
    public void init() {
    try {
    Locale.setDefault(Locale.US);
    } catch (Exception e) {
    System.err.println("Failed to set Locale, Caught Exception: " + e.getMessage());
    and adding this line to the java.policy to prevent "access denied (java.util.PropertyPermission user.language write)" errors.
    permission java.util.PropertyPermission "user.language", "read, write";

  • Extracting strings from binary data

    Hello,
    I am trying to extract string from a binary file.
    At the unix command line (sunos) I can just type;
    strings <filename>
    This is a nice way to get a list of the contents of a directory.
    Is there a way in pl/sql to extract strings from binary data ? An equiv to strings on unix/linux ?
    Thanks in advance.
    Ben

    Hi,
    If you do want to list the contents of a directory, there are other ways to do it. Here's a base implementation of a utility I wrote:
    create or replace and resolve java source named "Util" as
    import java.io.*;
    import java.sql.*;
    import oracle.sql.*;
    import oracle.jdbc.driver.*;
    public class Util {
        public static void listFiles(String directory, oracle.sql.ARRAY[] names)
            throws IOException, SQLException {
            File f = new File(directory);
            if(f==null)
                throw new IOException("Directory: "+directory+" does not exist.");
            String[] files = f.list(
                new FilenameFilter() {
                    public boolean accept(File dir, String name) {
                        // List all files
                        return true;
            Connection conn = new OracleDriver().defaultConnection();
            ArrayDescriptor descriptor = ArrayDescriptor.createDescriptor("VC_TAB_TYPE", conn);
            names[0] = new ARRAY(descriptor, conn, files);
            return;
    create or replace type vc_tab_type is table of varchar2(255);
    create or replace package util authid current_user as
        function list_files(p_directory in varchar2)
            return vc_tab_type;
    end;
    create or replace package body util as
        procedure list_files (
            p_directory in varchar2
            , p_filenames out nocopy vc_tab_type
        is
        language java
        name 'Util.listFiles(java.lang.String, oracle.sql.ARRAY[])';
        function list_files(p_directory in varchar2) return vc_tab_type
        is
            l_filenames vc_tab_type := vc_tab_type();
        begin
            list_files(p_directory, l_filenames);
            return l_filenames;
        end;
    end;
    /You can then query the filesystem as follows:
      1  select column_value as filename
      2  from table(util.list_files('c:\windows'))
      3  where column_value like '%.log'
      4* and rownum <= 10
    SQL> /
    FILENAME
    0.log
    AdfsOcm.log
    aspnetocm.log
    bkupinst.log
    certocm.log
    chipset.log
    cmsetacl.log
    comsetup.log
    DtcInstall.log
    FaxSetup.log
    10 rows selected.cheers,
    Anthony

  • Conversion from string "" to type 'Double' is not valid

    We're using BPC 7.5 MS and on patch level 111.02
    There's two front-end servers and one back-end.  we have about 100 users but concurrency is likely in the 50 range.
    We've been running extremely well for about 4 years but are now starting to run into problems.
    There are about 5-6 applications but none greater than 10 million records.  We optimize regularly.
    However over the past two months admin processes seem to take a lot longer.  Optimization now times out after about 1.25 hours and none used to take greater than 15 minutes.
    Today after processing dimensions we checked the application status and we were not able to check if it was available or not.  We got a pop up box saying
    conversion from string "" to type 'Double' is not valid
    I've processed dimensions and applications since and still this error persists.
    We're attempting a reboot to see if that helps but I've never seen this before and in combination with the slower admin processing I'm wondering if there's something drastic going to happen.
    Michael

    Hi Michael,
    for the poor performances you have to check the guides about performance on bpc if you have scheduled regurarly optimize during day and night (just verify that never factwb reach 50.000 and fac2 500.000 records) maybe you need to change some parameter on the server as MaxThreads.
    For the conversion string error on admin console see please this note 1803092 - Set application set status error
    Regards
         Roberto

  • XSU error oracle.xml.sql.OracleXMLSQLException: Conversion to String failed

    Appication Server: 10g, Database: Oracle 9i and Oracle 10g
    I have a table 'sw_icd2' in the database that has one column of XMLType.
    The code below, attempts to query this table as 'select * from sw_icd2' and display the result. I was able to execute this query in sqlplus.
    But when I run a program using XSU in JDeveloper:
    OracleXMLQuery qry = new OracleXMLQuery(conn, "select * from sw_icd2");
    XMLDocument domDoc = (XMLDocument)qry.getXMLDOM();
    domDoc.print(System.out);
    StringWriter s = new StringWriter(10000);
    domDoc.print(new PrintWriter(s));
    System.out.println(s.toString());
    qry.close();
    I get the following Error:
    "oracle.xml.sql.OracleXMLSQLException: Conversion to String failed"
    Any ideas on how I can resolve this issue? Your help would be appreciated.
    Thanks!

    Okay, it looks like the problem has something to do with the TIMESTAMP data type in tables.
    oracle.xml.sql.query.OracleXMLQuery can't seem to handle tables with the TIMESTAMP data type.
    this code ran fine on my machine :
    import oracle.jdbc.driver.*;
    import oracle.xml.sql.query.OracleXMLQuery;
    import java.lang.*;
    import java.sql.*;
    public class testXMLSQL {
         public static void main(String[] args) {
    try {
    // Create the connection
    System.out.println("before getConnection ");
    Connection conn = getConnection("scott","tiger");
    System.out.println("after getConnection ");
    // Create the query class
    OracleXMLQuery qry = new OracleXMLQuery(conn, "SELECT * FROM EMP");
    System.out.println("after OracleXMLQuery object created ");
    // Get the XML string
    String str = qry.getXMLString();
    // Print the XML output
    System.out.println("The XML output is:\n"+str);
    // Always close the query to get rid of any resources..
    qry.close();
    } catch(SQLException e) {
    System.out.println(e.toString());
    // Get the connection given the user name and password.!
    private static Connection getConnection(String username,
    String password)
    throws SQLException
    // register the JDBC driver..
    DriverManager.registerDriver(new
    oracle.jdbc.driver.OracleDriver());
    // Create the connection using the OCI8 driver
    Connection conn =
    DriverManager.getConnection(
    "jdbc:oracle:thin:@<server_name>:1521:<sid>",
    username,password);
    return conn;
    Then I created another table :
    create table emp_test as select * from emp;
    added a timestamp to it :
    alter table emp_test add (time timestamp(6));
    and filled it with timestamp information :
    update emp_test set time = timestamp'2005-09-22 09:26:50.124';
    ran the same code but changed the SQL to :
    "SELECT * FROM EMP_TEST"
    and got the error message :
    The XML output is:
    <?xml version = '1.0'?>
    <ERROR>oracle.xml.sql.OracleXMLSQLException: Conversion to String failed</ERROR>
    looks like bug in OracleXMLQuery object??

  • Synch Error: String or binary data would be truncated.

    I kicked off an inital synch for WebTools 2007 (may also be an issue in 596) and I had 1 synch error for SBOPartner:
    String or binary data would be truncated.
    The statement has been terminated.
       at netpoint.api.data.DataFunctions.Execute(String SQL, IDataParameter[] parameters, String connectionstring)
       at netpoint.api.NPBase.MarkSynched(String SynchID)
       at NetPoint.SynchSBO.SBOObjects.SBOPartner.SBOToNetPoint(SBOQueueObject qData)
       at NetPoint.SynchSBO.SynchObjectBase.Synch()
    I traced the sql log and found the problem was related to addresses. The synchid only allows 50 characters but my synchid was 51 characters (COMINF, Communication Infrastructure Corporation, S). Anyway, to fix I modified the table to allow 100 characters and reran the synch. I know an upgrade will set it back to 50 but at least it's working now.
    I tried to post this to support as a bug but I couldn't figure out how (as usual) or the authorization stuff changed so I figured I would post it here so hopefully the devs will see this and update the code.
    Steve

    Thanks Shawn ... My version of Netpoint is 2007.0.620.0 and the synch manager is 2007.0.620.35247. I'm not sure what patch level this means I am on though.
    Steve

  • String or binary data would be truncated - different service packs on publisher vs distributor

    We have transactional replication where the publisher is 10.0.4067 and the distributor is 10.0.4000.  The distribution agent will periodically will fail with the following error: String
    or binary data would be truncated
    SQLSTATE 22001] (Error 8152). The tables on the publisher and subscriber are all the same data type. Could the version difference be causing this issue?  Do we need
    to upgrade the distributor sql server (different server than the publication server)?

    Hello,
    Just as others post above, the difference service pack version between publisher and distributor should not cause this issue.The replication workfolw between publisher and distributor is through the Log Reader Agent which
    runs at the Distributor, it reads the publication transaction log in publisher and copies those transactions in batches to the distribution database at the Distributor.
    You can refer to the following thread which about the similar issue casused by a long stored procedure:
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/5bbf2c8c-a5c0-4a22-b30b-82b6ce4f1fea/an-error-prevents-replication-from-synchronizing-string-or-binary-data-would-be-truncated?forum=sqlreplication.
    Regards,
    Fanny Liu
    If you have any feedback on our support, please click here.
    Fanny Liu
    TechNet Community Support

  • "String or binary data would be truncated" and field specifications

    Hi all,
    i have "String or binary data would be truncated" error when i try to execute an insert statment.
    can i find witch field is affected by this error? (for return it to the user)
    thank's all

    As far as I am aware, there's no way to determine which column's length has been exceeded.
    You should add code into your stored procedure to check the lengths of variables before inserting their values into your tables, raising an error if necessary - see the example below.
    Again I stress that it would be better to modify the client application's code to either warn the user or to limit the number of characters they can enter into a field.
    Chris
    Code Snippet
    --This batch will fail with the SQL Server error message
    DECLARE @MyTable TABLE (MyID INT IDENTITY(1, 1), MyValue VARCHAR(10))
    DECLARE @MyParameter VARCHAR(100)
    --Create a string of 52 chars in length
    SET @MyParameter = REPLICATE('Z', 52)
    INSERT INTO @MyTable(MyValue)
    VALUES (@MyParameter)
    GO
    --This batch will fail with a custom error message
    DECLARE @MyTable TABLE (MyID INT IDENTITY(1, 1), MyValue VARCHAR(10))
    DECLARE @MyParameter VARCHAR(100)
    --Create a string of 52 chars in length
    SET @MyParameter = REPLICATE('Z', 52)
    IF LEN(@MyParameter) > 10
    BEGIN
         RAISERROR('You attempted to insert too many characters into MyTable.MyValue.', 16, 1)
    RETURN
    END
    ELSE
    BEGIN
         INSERT INTO @MyTable(MyValue)
         VALUES (@MyParameter)
    END
    GO

  • String or binary Data would be truncated. Error detected by database DLL

    Having problems generating two reports in Crystal Reports v8.5. I can run it on my machine and one on one of my Terminal Server(TermA). However when I tried to generate the same two reports on my second terminal server(TermB), it crashed and I get the following error messages: ODBC error: String or binary data would be truncated and Error detected by database DLL We have one set user ID and password to generate all of our Crystal Reports.
    Steps taken:
    Reinstall Crystal on TermB server and did a fresh installation of Crystal 8.5 on another workstation.  Ran the reports and the result were the same (unable to generate the report) same errors messages.
    Please HELP...
    Thanks.

    Terminal Server was not supported in CR 8.5

  • When i tried to insert data in a database the following error is displaying, error : String or binary data would be truncated

    Hi,
         can any anyone give me a solution for this.

    It is pretty old /famous error
    http://dimantdatabasesolutions.blogspot.co.il/2008/08/string-or-binary-data-would-be.html
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

Maybe you are looking for

  • MOTION IS NOT READING ALPHA CORRECTLY (Frustrated, Please Help)

    I've exported a file with an alpha channel from Motion 4, and when I pull it into another project, it is not recognizing the alpha channel. In the project tab area, it displays with a checkerboard as if it has alpha ... I've checked the alpha interpr

  • Intercompany Transaction Error

    Hi I'm currently having an issue doing intercompany transaction In FB50 the following transaction have been made 8xxxxxx DR 10000 ( Cocode 1000) with tax type A0 6xxxxxx CR 10000 ( Cocode 2000) with tax type V0 When i try to simulate it gave me an er

  • Cannot find Internet Connect Icon

    I am using Leopard 10.5.4. I want to setup a VPN connection and found an article which describes how to go about setting the VPN connection. But it uses Internet Connect icon and according to the article it is found in the 'Applications' folder. I ca

  • Setup Package NTW04s Sp15 :"Could not retrive device Id" and other

    Dears, we configured the setup package creation with NTW04s SP15: One device configurator for the MI70 Client Jsp; one device configurator for the DB2e; one device configurator for the MAM application. We defined the Parameter Set into the device con

  • Two songs did not download from an album I purchased. What do I do now?

    Hello, I just downloaded an album, and 2 of the songs were not downloaded. An error message came up each time saying iTunes was not able to download these songs. How do I download the 2 missing songs? Thank you