Results 1 to 8 of 8
  1. #1
    Arun_N is offline Member
    Join Date
    May 2011
    Posts
    21
    Rep Power
    0

    Smile Why Metadata is different in different databases?

    I tried to use ResultSetMetaData.getColumnDataTypeName to get Datatype of an Attribute, but am getting Number for INTEGER,FLOAT and DOUBLE datatypes in Oracle, and DATETIME for DATE , TIMESTAMP and TIME in Access , i am writing one generic method to update table using file. can anyone please tell me how to get a datatype name given while creating table.


    Thank you

    Arun N

  2. #2
    Arun_N is offline Member
    Join Date
    May 2011
    Posts
    21
    Rep Power
    0

    Default Re: Why Metadata is different in different databases?

    am waiting :(:(

  3. #3
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,770
    Blog Entries
    7
    Rep Power
    21

    Default Re: Why Metadata is different in different databases?

    Quote Originally Posted by Arun_N View Post
    I tried to use ResultSetMetaData.getColumnDataTypeName to get Datatype of an Attribute, but am getting Number for INTEGER,FLOAT and DOUBLE datatypes in Oracle, and DATETIME for DATE , TIMESTAMP and TIME in Access , i am writing one generic method to update table using file. can anyone please tell me how to get a datatype name given while creating table.
    I think Access is wrong; the Oracle data types INTEGER, FLOAT and DOUBLE can be mapped to the Java Number type but a type DATETIME doesn't even exist in Java; it should be a Timestamp type i.m.h.o.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  4. #4
    Arun_N is offline Member
    Join Date
    May 2011
    Posts
    21
    Rep Power
    0

    Default Re: Why Metadata is different in different databases?

    I just want to get the datatype through java code , which i used to create table, is it possible? for example if i used Integer as a datatype while creating attribute , i want same value as INTEGER is it possible in oracle? since am writing genric class to insert,Update or delete from any table , while using prepared statement i might need the exact datatype if it is Integer or float or double.

  5. #5
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,770
    Blog Entries
    7
    Rep Power
    21

    Default Re: Why Metadata is different in different databases?

    Quote Originally Posted by Arun_N View Post
    I just want to get the datatype through java code , which i used to create table, is it possible? for example if i used Integer as a datatype while creating attribute , i want same value as INTEGER is it possible in oracle? since am writing genric class to insert,Update or delete from any table , while using prepared statement i might need the exact datatype if it is Integer or float or double.
    I don't know what the Oracle database does, e.g. are you able to insert floating point value, say, 123.456 in a column that was declared of type Integer? (of course only 123 would be stored). If so, Oracle can only return the type/class Number for that column. It's a can of slimey worms if both Java and your database can perform implicit casts ...

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  6. #6
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default Re: Why Metadata is different in different databases?

    For the number types look at the scale and precision values to determine the actual type you want. For "DATETIME" there should also be something equivalent (possibly even the same fields with other values, but I doubt that).

  7. #7
    Arun_N is offline Member
    Join Date
    May 2011
    Posts
    21
    Rep Power
    0

    Default Re: Why Metadata is different in different databases?

    we can insert even 3.5 to double datatype which can also be float, or we can insert 3.0 to double which can also be integer and float

  8. #8
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default Re: Why Metadata is different in different databases?

    Like I said, use the ResultMetaData and inspect the scale and precision of the field definition, that will at least tell you whether it wants a whole number (int, long) or floating point (float, double) and whether the "length" is larger than an int/float will allow telling you that it is a long/double.

Similar Threads

  1. Create metadata file
    By kate88 in forum Advanced Java
    Replies: 0
    Last Post: 01-20-2011, 06:14 PM
  2. Accessing metadata of files
    By LianaN in forum New To Java
    Replies: 11
    Last Post: 09-19-2010, 06:49 PM
  3. jpg metadata
    By dinosoep in forum Java 2D
    Replies: 1
    Last Post: 11-20-2009, 04:11 PM
  4. JDO - defining the persistence using metadata
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 03-17-2008, 08:50 AM
  5. Media Metadata
    By soulspirit in forum Advanced Java
    Replies: 0
    Last Post: 11-27-2007, 12:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •