Java & NUMBER type

How can I get a NUMBER(5, 7) from a db Oracle.
I've tried with rs.getDouble, but i don't get espected result!
I have jdk1.2.2 and I use a thin driver.

useoracle.jbo.domain.Number Number n = new Number(100);
java.lang.float f = n.floatValue();Timo

Similar Messages

  • Does the Number type in Oracle always map to the Java BigDecimal object

    We have noticed that whenever we create a column in a table of type smallint, integer, real, etc. that the type in sqlplus always shows up as number(x). Our problem is that this type always seems to map to java.math.BigDecimal through JDBC. Is this a bug in the JDBC drivers???
    Put another way when I create a column of type smallint I expect that after performing a query I should be able to call the getShort method on the result set in order to get the value from the afore mentioned column. But instead I get a ClassCastException because the Java type for the column is actually a java.math.BigDecimal.
    Thanks,
    Keith
    [email protected]

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Keith Nielsen:
    We have noticed that whenever we create a column in a table of type smallint, integer, real, etc. that the type in sqlplus always shows up as number(x). Our problem is that this type always seems to map to java.math.BigDecimal through JDBC. Is this a bug in the JDBC drivers???
    Put another way when I create a column of type smallint I expect that after performing a query I should be able to call the getShort method on the result set in order to get the value from the afore mentioned column. But instead I get a ClassCastException because the Java type for the column is actually a java.math.BigDecimal.
    Thanks,
    Keith
    [email protected]<HR></BLOCKQUOTE>
    ~~~
    The possible Java types to which SQL NUMBER type can be materialized to include
    oracle.sql.NUMBER
    java.lang.Byte
    java.lang.Short
    java.lang.Integer
    java.lang.Long
    java.lang.Float
    java.lang.Double
    java.math.BigDecimal
    byte,short, int, long, float, double
    For a complete listing for all datatypes mappings refer the Oracle8i JDBC Developer's guide and reference.

  • Name of an int ( e.g. java.sql.Types )

    I have the sql.Types code as an int number and want to display the name. Is there a straightforward method or do I have to search it in a loop like here ?
    String getName(int i) {
    for (Field f: java.sql.Types.class.getFields()) {
         if (f.getType().equals(int.class)) {
              if (f.getInt(f.getType()) == i) {
              System.out.println( i + " = "+f.getName() );
              // e.g.               8 = DOUBLE
              return f.getName();
    }This question is not specific to java.sql.Types I guess (that's why I post here).
    A dedicated hint for sql is appreciated as well, however ;)

    Seems the loop is required and it works (in no time, there aren't too many Fields)
         if (f.getInt(f.getType()) == i) {Having a closer look, I do not understand the inner f.getType() , however.
    f.getInt() requires an object, but anything, including null, works ?!
    Any hint, or link where to learn about java.lang.reflect.Field, please ?

  • RowFilter.NumberFilter: can't handle "mixed" concrete Number types

    cross-post from
    http://stackoverflow.com/questions/7993546/rowfilter-numberfilter-cant-handle-mixed-concrete-number-types
    Copying here:
    Happens at least one of the values (values == value in RowFilter, value in entry) is a decimal. Here's a failing test:
    @Test
    public void testRowFilterNumberMixCore() {
        TestEntry entry = new TestEntry(1.2f);
        RowFilter filter = RowFilter.numberFilter(ComparisonType.AFTER, 1, 0);
        assertTrue(entry + "must be included " + filter, filter.include(entry));
    }the output is:
    junit.framework.AssertionFailedError:
    [entry: 1.2] must be included [RowFilter: ComparisonType = AFTER, comparableValue: 1, comparableClass: class java.lang.Integer]The reason is that NumberFilter falls back to comparing the numbers by their number.longValue() if they are not the same class (and by that comparable to each other)
    Knowing that detail, the test failure is not astonishing (in hind-sight, would have never thought of that being an issue ;-) One level of defense is to make sure - in client code - that the numbers to compare are of the same class. That's not always possible (think f.i.: a tableColumn with columnClass Number) So I'm wondering if/how to improve on the fallback. Something like:
            if (one instanceof Comparable && one.getClass() == other.getClass()) {
                // same class, use comparator
                return ((Comparable) one).compareTo(other);
            if (areIntegers(one, other)) {
                // all integers, use longValue
                return longCompare(one, other);
            if (areDecimals(one, other)) {
                // anything to do here?
            // at last resort convert to BigDecimal and compare those:
            BigDecimal bigOne = new BigDecimal(one.toString());
            BigDecimal bigOther = new BigDecimal(other.toString());
            return bigOne.compareTo(bigOther);Doing so, makes the test pass - I'm a bit weary about hidden (read: unknown to me :) pitfalls. Any warnings/alternatives highly welcome!
    Thanks,
    Jeanette

    FYI: nothing much turned up anywhere, so decided to solve as outlined.
    Thanks for your interest :-)
    Jeanette

  • What is the point of Precision and Scale in Number Type?

    Version :11.2
    What is the point in having PRECISION and SCALE in number type? If you create the column with just NUMBER ie.without
    specifying precision or scale , you can enter numbers with any precision and scale.
    SQL> select * From v$version where rownum < 2;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    SQL> create table t1 (col1 number);
    Table created.
    SQL> insert into t1 values (223.9939394);
    1 row created.
    SQL> insert into t1 values (88.228384);
    1 row created.
    SQL> insert into t1 values (9.34);
    1 row created.
    SQL> insert into t1 values (000.00);
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select * from t1;
          COL1
    223.993939
    88.228384
          9.34
             0Did you ever have a business scenario where a Numerical column should store values only with a fixed precision and scale ?

    Omega3 wrote:
    Version :11.2
    What is the point in having PRECISION and SCALE in number type? If you create the column with just NUMBER ie.without
    specifying precision or scale , you can enter numbers with any precision and scale.
    SQL> select * From v$version where rownum < 2;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    SQL> create table t1 (col1 number);
    Table created.
    SQL> insert into t1 values (223.9939394);
    1 row created.
    SQL> insert into t1 values (88.228384);
    1 row created.
    SQL> insert into t1 values (9.34);
    1 row created.
    SQL> insert into t1 values (000.00);
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select * from t1;
    COL1
    223.993939
    88.228384
    9.34
    0Did you ever have a business scenario where a Numerical column should store values only with a fixed precision and scale ?Lots of business requirements for specific precisions and scales.
    A persons Age may required to be stored as whole numbers of no more than 3 digits.
    A sum of money may required to be stored with no more than 2 decimal places of accuracy e.g. GB Pounds and Pence or US Dollars and Cents
    A unit of length may required to be stored in metres with 2 decimal places for centimetres
    A shoe size may be required to be stored with one decimal place for half sizes
    etc.
    etc.
    Yes, you may just create all of them as generic NUMBER datatype, but creating them with precision and scale can provide additional information about the limitations expected for the values stored, especially for things like reporting tools that may use the specified precision and scale to determine how to display the values automatically (by default).
    If you start questioning "what's the point?" then you may as well say what's the point in having a NUMBER datatype when we can store numbers in a VARCHAR2 datatype? or what's the point in having a DATE datatype when we can stored dates as VARCHAR2 datatype? etc.
    No point in asking such a question because there's almost always a point to these things (and if there isn't they get deprecated in later versions).

  • How to update the null values to some number on the NUMBER type of column

    Hello All,
    I have one NUMBER type of column in DB table. It has some (null) values. I want to update with value 1. I tried to run the Update statement , It gives 0 rows updated.
    SELECT objectid,attr20 FROM table;
    object id attr20
    ====== ====
    fff70b67-8d54-4ad7-bc57-7b40a0d8b219     (null)
    cac5264a-b363-487b-bfe6-6b84d60064e9     (null)
    2fc2a626-51d8-401c-9495-18aacd4c35c8     (null)
    1b60bfa4-ff68-4488-adf6-2a83528c0e20     (null)
    1c662829-24c1-4b3c-9289-0128e170c043     5
    74f11331-545b-435f-bf4b-f57c7a6b4500     2
    c941c1ac-a18e-47ec-843c-dbe2a5b51001     0
    d7eba203-93c0-48ea-a109-9b06015ef387     0
    eba72fa3-21d8-4489-bb93-917ebbd67de2     0
    I ran following query but no success.
    UPDATE eb_tcsservfnadoc SET attr20 = 1 WHERE attr20 = NULL
    0 rows updated
    UPDATE eb_tcsservfnadoc SET attr20 = 1 WHERE attr20 = null
    0 rows updated
    UPDATE eb_tcsservfnadoc SET attr20 = 1 WHERE attr20 = ''
    0 rows updated
    UPDATE eb_tcsservfnadoc SET attr20 = 1 WHERE attr20 =' '
    Error starting at line 1 in command:
    UPDATE eb_tcsservfnadoc SET attr20 = 1 WHERE attr20 =' '
    Error report:
    SQL Error: ORA-01722: invalid number
    01722. 00000 - "invalid number"
    *Cause:   
    *Action:
    can some one help me out to update such values ????

    Hi,
    "=" will not work for NULL values. Please remeber two NULL values are NOT same. Try IS operator.
    UPDATE eb_tcsservfnadoc SET attr20 = 1 WHERE attr20 IS NULLRegards,
    Avinash

  • Java Step Types with Java Virtual Machine higher than java-6u16?

    Documentation of Java steps says, that these steps are tested with java version 6 update 16. I am talking about the java step types that can be found in directory <TestStand Public>\TestStand 2010\Examples\Java. 
    If I install another java version, e. g. java 7, step "Start JVM" will exit with an error "-4" and error message "Could not launch JVM.". While Debugging source code of JavaCall.dll, I figured the failing code line out:
    "fpCreateJVM(&jvm,(void**)&env,&vm_args);" is the execution of function "JNI_CreateJavaVM" and returns error code -4.
    Till now I could not find out, why the jvm does not start. I guess -4 means "Insufficient memory to create the JVM." (http://zone.ni.com/reference/en-XX/help/370052J-01/tssuppref/infotopics/java_steps_errors/)
    Has anyone an advice for me?

    This post gave me a hint: http://stackoverflow.com/questions/3400292/jni-enomem-from-jni-createjavavm-when-calling-dll-that-us...
    Though my development computer has enough ram, jvm is started within the Teststand process which offers limited memory. I changed JavaCall.c and added parameter "-Xmx64m" to the jvm creation call. Now it works with jre 7.
    Because memory space Teststand offers to the jvm is different on different computers, an implementation would be nice that checks how much memory is available and then passes the calculated <MEM> as parameter "-Xmx<MEM>m". Here is an example implementation: https://forums.oracle.com/forums/thread.jspa?threadID=1546540

  • Java.sql.types and oracletypes

    There appear to be difference in the way the constants are mapped in java.sql.types vs oracletypes(). For example date is '91' in oracletypes and '93' in java.sql.types. The DatabaseMetaData.getColumns() function reports data_type as a java.sql.type. Is there any mapping available from one to the other.
    Thanks

    Erm,
    One way to find out, I reckon.
    Good Luck,
    Avi.

  • External SOAP client Accessing Webservice using built in Java Data type

    We have built a webservice and deployed it on WLS. We accessed this from a swing
    client it works fine.The webservice methods uses non-built in JAVA data types
    as parameters.These are Value Objects and the JAVA Serializer and Deserializer
    classes are generated using Ant task itself.The client coding uses Value objects
    given by the Client_jar (generated using <Clientgen> ant task) to pass to the
    webservice. We dont want to go by this way.Is there anyway were in we can pass
    parameters to the method which expects non-built in java datatypes?
    Why i am asking this is, i want to know how an external client (.Net client )
    will be able to exceute my webservice (i.e., passing the required Object which
    the method is expecting)?

    Hi Anish,
    Well first off, your web service doesn't send or receive "objects". It only sends
    and recieves XML, which is in turn converted to/from Java objects at invocation
    time. Second, a .NET (or Perl, or Python, or C++) client will be able to call
    your web service, because the wsdl.exe tool (for .NET) will generate "programming
    language specific" objects from the <types><schema> elements, in the WSDL of your
    web service :-) The wsdl.exe tool will create C# objects from the WSDL, that will
    convert XML to/from C# when your web service is called. That's the beauty of XML
    schema - it's a "universal typing system", so it's not tied to a particular programming
    language. The only issue is whether or not the web services platform vendor's
    XML Schema/WSDL processor, can successfully process the WSDL. Some vendors have
    more complete implementations of the WSDL and XML Schema specs than others, so
    expect varying success here. The one in WLS 7.0 is pretty good, so you shouldn't
    have too many problems consuming WSDL generated by .NET tools (or any other tool
    for that matter).
    Regards,
    Mike Wooten
    "Anish" <[email protected]> wrote:
    >
    We have built a webservice and deployed it on WLS. We accessed this from
    a swing
    client it works fine.The webservice methods uses non-built in JAVA data
    types
    as parameters.These are Value Objects and the JAVA Serializer and Deserializer
    classes are generated using Ant task itself.The client coding uses Value
    objects
    given by the Client_jar (generated using <Clientgen> ant task) to pass
    to the
    webservice. We dont want to go by this way.Is there anyway were in we
    can pass
    parameters to the method which expects non-built in java datatypes?
    Why i am asking this is, i want to know how an external client (.Net
    client )
    will be able to exceute my webservice (i.e., passing the required Object
    which
    the method is expecting)?

  • Java.sql.Types.??????

    I know clob columns in an oracle database are java.sql.Types.CLOB. What are long raw columns defined as java.sql.Types.???
    Thanks in advance,
    kmw

    Hi ,
    Long has no correspondng type in Oracle.sql.Types.So u can access it using the getOBject and setObject.Why do u need to defing the long ?Is it for use i the getter and setter methods of ResultSet or Statements.If so , u have to use streaming and so there is really no need to worry abt the type definition as u are defaulting to an AsciiStream.
    Hope it helps.

  • IN sharepoint 2013 custom list number type column ,decimal point shown as comma

    i have a sharepoint 2013 site in which a custom list is there. In number type field while i enter decimal number, instead of decimal point comma is comming. Any help appreciate
    Thanks sanjay

    Hi SanjayPradhan,
    According to your description, my understanding is that when type decimal point in number field, it became comma.
    I made a test in my enviroment and it works like a charm.
    Did you have some formula in that column ?
    If yes, I suggest you can check the formula in list settings->columns.
    If No, I suggest you can recreate a new list and number field to test whther it works.
    Best Regards
    Zhengyu Guo
    TechNet Community Support

  • How to define field of number type in ecs file

    Hi B2B Experts,
    I need some help. In the detail record of my ecs file, i need to define a filed as number. Basically the data coming in the data file is a dollar amount. It is a number type.
    The number length maximum length is 6, The spec file says that field should be like below....
    9(04)V99
    The data came in the text file as 013100, so according to the business it is like 131.00 but as i defined the field as string, it is taking it as 13100. I want to define that field as a number type and it should consider keeping that number with two digits precision i.e.,decimal part. Please help me in this regard.
    I believe i should define the type as number and the i dont know what to keep for the format ?
    Thanks,
    N

    Naresh,
    What are your requirements? If I understood it correctly, you will be getting data without decimal and you want B2B to add decimal accordingly. If this is the case then I don't think it should be done at B2B rather this should be performed at middleware.
    Please let us know your exact requirement if I interpreted it incorrectly.
    Regards,
    Anuj

  • Working with NUMBER types in ASP

    Hi,
    We are having big problems working with Oracle from a ASP application. We return data from the Oracle (8i) database using Oracle ODBC driver (9.2). However, whenever Oracle returns NUMBER columns (Number(8)), we cannot work with them in ASP because of an ASP VBScript bug that prevents adNumeric from working withouut explicitly casting to numbers (see
    http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/Q195/1/80.ASP&NoWebContent=1&NoWebContent=1 for more info).
    I was wondering if there is any other way to get round this in ORacle - can I set somethign in the ODBC driver that instead of returning the data as adNumeric, it returns it as some other number type that wont exhibit this problem?
    Thanks in advance!

    Anyone :-(

  • Create table dinamically using java sql types?

    Hi! I've an application that reads an XML file. This file contains de definitions of some tables, using java sql types. For example:
    <dbtable>
      <dbtablename>Name of table</dbtablename>
      <dbtablefield>
        <name>Name of table field</name>
        <type>java.sql.Types.VARCHAR</type>
        <length>10</lenght>
        <canNull>0</canNull>
        <isPK>1</isPK>
      </dbtablefield>
    </dbtable>That's a little example of one table, with one field. Is a java.sql.Types.VARCHAR (or is equivalent in int), which has a size of 10, it cannot be null and is a primary key for the table.
    Now, the lenght, null, and primary keys are not problem at all. What I want to know, is how do I create de table using the java.sql.Types. I mean, I don't want to hard code:
    String s = "CREATE TABLE name (COLUMN VARCHAR(10)...";Instead, I want to use some "wild cards", as are used in PreparedStatement. The idea of this is that no matter what DB I'm using, I must always be capable of creating the tables not worrying for the DB. I mean, I must be able to create the table in Oracle, SQL Server, DB2, etc., using the same XML and the same java class.
    Something like:
    String s = "CREATE TABLE name (COLUMN ? (10)...";
    someobject.setObject(1,java.sql.Types.VARCHAR);
    someobject.execute(); //create tableIs this possible? Or do I have to make a map for each DB?
    Thanks a lot for your help! Dukes available!

    you can provide some fields at runtime..
    for example
    "CREATE TABLE name (COLUMN" + arg[1] +"(10)..."
    here arg is the string array passed into the main.

  • Simple java archive type deployment is invalid in Jdeveloper  9031

    Hi All,
    If I choose a Simple Java archive type of deployment of a jsp tag lib project in Jdeveloper the archive does not include the directory layout recursively. Ex. I get this.
    c:\> jar tvf test.jar
    64 Sat Jan 01 23:53:48 PST 2000 META-INF/MANIFEST.MF
    1300 Sat Jan 01 23:53:48 PST 2000 META-INF/autodate.tld
    5772 Sat Jan 01 23:53:48 PST 2000 test/autodate.class
    Where if I do it the archiving from the comman line. i.e
    c:\> jar cvf test.jar META-INF test
    I get
    0 Wed Feb 26 20:52:42 PST 2003 META-INF/
    68 Wed Feb 26 20:52:42 PST 2003 META-INF/MANIFEST.MF
    1300 Wed Feb 26 20:12:42 PST 2003 META-INF/autodate.tld
    0 Wed Feb 26 20:12:42 PST 2003 test/
    5772 Wed Feb 26 20:12:42 PST 2003 test/autodate.class
    The latter is a valid archive that I can use for taglib deployment. The former, i.e the Jdev deployed archive does not work. The jsp does not find the tag library.
    What is the archiving tool that jdeveloper uses??
    Why is it different from doing a command line archive??
    Is there anyway I can instruct the deployment tool to include the directory tree in the archive??
    - Manish

    Hi Lynn,
    The Archive looks exactly the same and the jsp fails to find the tld from the classpath.
    64 Fri Apr 04 13:53:48 PST 2000 META-INF/MANIFEST.MF
    1300 Fri Apr 04 13:36:48 PST 2000 META-INF/autodate.tld
    5772 Fri Apr 04 13:42:48 PST 2000 test/autodate.class
    Note, this is a problem only when using the Tag lib autodiscovery mechanism of JSP 1.2 where the tld can exist anywhere in the classpath under META-INF and the path is not explicitly specified in the jsp.
    - Manish
    - Manish

Maybe you are looking for

  • Java.lang.NoClassDefFoundError while calling a java class from BPEL

    Hi, I'm calling a java class to convert JSON to XML using BPEL. I have imported all the necessary jar files in the project and compiling done successfully. But at runtime , i get the java.lang.NoClassDefFoundError: net/sf/json/JSON error. For this i

  • My iphone was stolen, can the thief get into my email if I've contacted my carrier and gotten them to block data etc?

    So immediately after my iphone was stolen, I contacted the police and my cellphone carrier and the carrier cancelled/blocked all incoming/outgoing messages and data. I changed my gmail password that I had associated with my phone, just wondering if t

  • Create a database - MS Access + JFrame.

    I have a quiz application that writes questions and answers to an access database and a second app that retrieves them and then gives you a score - with hints during and explanations at the end. It is well. What I would really like to do is to use a

  • Froeign Currency valuation resetting for GL balances

    Hi All, I executed FAGL_FC_VAL with open item and non open item accounts. But system has not updated the valuation results in the table FAGL_BSBW_HISTRY for non open item accounts. Is this is the standard behaviour? Due to some errors I had to reset

  • Keychain Nuclear Option?

    I did a 10.5 "upgrade" archive-install, and since then the Keychain.app has been hosing me. I've tried many things, including, most recently, deleting everything in ~/Library/Keychains and trying to reset everything from Keychain.app. I also deleted