Automatic types in jdbc

Hey guys I have a question about jdbc. So I am sending quieries to the server using jdbc and it returns me a resultset which is all fine. Then I am writing all that to the CSV file separated with commas thats easy too. I am using meta data to extract the number of colums and just loop through the number of columns building up the string and then writing this string to a file which is all fine too.
Now the question that I have is that not every column is the same data type. Some columns are varchar2 some are integers and some are dates I am using the getColumnTypeName method to extract that information.
What I want to do is NOT something like this:
is this a Date
ok if it is then do ResultSet.getDate(integer)
is this Integer
so on
is this Varchar2
so on
I dont want to do that..I want it to somehow be automatic is that possible? Can you guys help me how to have it aumatically choose which methods according to the type it is.
Thank you.

Yeah actually you're right. If I do a getString on
the Date it gives the date plus the time..and thats
not what I need so yeah..I guess I am not gonna
really bother with it.That isn't what I meant.
Timestamp fields are usually the field that is most likely to require a variation. (Currency follows that.) Thus what the database/java puts out might not be what you want. Consider that java will put out whatever the OS is set to so is that acceptable to you?

Similar Messages

  • Can I set a text field to automatically type in caps when I have converted a form to fillable in ADO

    When people get to the field where they have to enter their postal code, I want it to automatically type in capital letters whether they do that or not.

    Is there something like this that will allow me to type only the first letter of each word in a fillable field as a capital letter?
    For example:
    This Is What I Want It To Look Like

  • My ipad automatically jumps from one app to other. it automatically types things randomly. i dont know what it wrong. Have shown it in a service center. they have done factory reset but problem still persist.

    my ipad automatically jumps from one app to other. it automatically types things randomly. i dont know what it wrong. Have shown it in a service center. they have done factory reset but problem still persist.

    Likley a defective touchscreen.

  • When I get a date field value using the Oracle thin (type 4) JDBC driver...

    ....in 'DD-MMM-YY' format from an Oracle 8i database and pass it in to the java.util.Date() constructor, I get a IllegalArgumentException. This error doesn't occur when I use the type 2 driver, so it is apparently a driver-specific thing. It happens on both Win32 and Linux.
    Has anyone seen this before? Is there a newer version of the Oracle thin (i.e., type 4) driver than is listed here?
    http://web77-02.us.oracle.com/software/tech/java/sqlj_jdbc/content.html
    Thanks,
    Tom
    [email protected]

    Yup, that original post didn't make much sense, did it? Let's try again.
    I've got an EJB app that runs on WebLogic 6.0 (on Solaris in production, on Win2K for development) and accesses an Oracle 8i database. This app currently uses the Oracle type 2 JDBC drivers. All is well.
    So I wanted to see how it would run on Linux. I've got a Redhat 7.1 box handy, so I installed the JDK and WL6.0 and slapped the ear file on there. Problem! Can't deploy because there are no Oracle drivers on this machine!
    Makes sense. So I started looking around, and it seems installing Oracle on a RH 7.1 box involves patching glibc and other such nastiness. So let's just try the type 4 JDBC driver - no glibc patch, no shared object libraries, just good 'ol pure Java talking to Oracle on port 1521.
    Once I had the URLs and whatnot set up, the app connected to the DB just fine, created the connection pool, read some data, etc. But when my app read a date from the DB and instantiates a new java.util.Date object, I got an IllegalArgumentException - i.e., the date can't be parsed.
    "Hmm... that's odd", I thought, so back I went to my trusty Win2K machine, modified my configuration files to use the type 4 driver and - same error! So I switched back to the type 2 driver - and everything works fine, Dates and all. Hmmm.....
    As you correctly state, that Date constructor is deprecated and I should use DateFormats and GregorianCalendars and whatnot instead.
    But has anyone seen this weird behavior before - code that works fine on a type 2 driver starts throwing exceptions when used with a type 4 driver? Anyone have any solutions?
    Thanks much,
    Tom

  • SOA does not commit to database using type 4 JDBC adapter.

    We are using Oracle SOA suite 11.1.1.3 and have successfully configured a type 4 JDBC adapter "ViaServ" to enable polling. These kinds of adapter are configured in the SOA suite as non X Data Source adapters and transaction has been set to "Supports Global" with the Logging Last Resource option.
    We also created the connection pool to for this Data sources. The Polling SQL for logical delete (SELECT) is working great and the After read SQL Update is happening successfully. Some how the updates are not being committed to the database. The process is not throwing any exceptions/errors etc.
    I shall really appreciate help.
    thanks

    SOLVED:
    1.) The JDBC type 4 adapter was installed in the WLS HOME/lib directory and SOA server/modules/ext directory.
    2.) Change the setComEnv.sh, modify the WLS_CLASSPATH variable to point to the WLS_HOME/lib/jadbcjarfile.jar
    3.) Restart admin servers and managed server.

  • WLS 8.1 Type 4 JDBC Driver SQL Server sp_prepare/sp_execute

    Hello,
    I have a question regarding performance troubleshooting in a production situation using the WLS 8.1 Type 4 JDBC Driver for SQL Server and SQL Server 2000.
    This driver compiles a sql statement on the sql server using sp_prepare(), saving a handle to it. It will execute the statement using sp_execute(). Subsequent uses of the same statement will skip the sp_prepare(), and just call sp_execute(). So, ideally, for a particular statement, you should see one sp_prepare, and a lot of sp_execute's.
    My WLS app is running along in production, and I detect a performance problem of some sort on the sql server, such as excessive IO, or blocking.
    I turn on the sql server profiler, and I can see a bunch of
    sp_execute 123, 'one', 'two'
    sp_execute 123, 'foo', 'bar'
    with bad IO. How do I determine what the original SQL was that was used in the sp_prepare?
    The only way I can see to do this is to have the sql server profiler always running to catch every sp_prepare. I can't believe that this is a best practice.
    How are you all handling this type of situation?
    Thanks,
    Dave

    Dave Ballard wrote:
    Hi Joe,
    Thanks for the suggestions. The main issue I have with both is that they
    require a server restart to enable. Can't do that on my production system.
    The best I've come up with since I posted is to locate the poor
    performer/blocker real-time via sysprocesses, then use the sqlhandle column
    to call fn_get_sql to get at least some of the sql submitted with sp_prepare().
    Not pretty and difficult to do on a busy system.
    What's bugging me about the sp_prepare/sp_execute technique used by the driver is:
    1) sp_prepare/sp_execute don't seem to be documented anywhereThey are internal to SQLServer, so it'd be MS to document them or not.
    2) It is at best inconvenient to have to troubleshoot performance issues (requiring
    a server config change, server restart, and manual reconcile of two different,
    possibly very large, logs based on timestamp).
    Your idea to disable the stored procedure cache is interesting, but still requires
    a server restart to enable, and another to disable.
    To me this is a large step backwards in manageability of my system. What I don't
    understand is that I don't see much discussion about this topic on any forums,
    so I wonder if I'm just missing something here (maybe everyone's using Oracle).No, the same sorts of issues would be needed with Oracle. DBMSes must make tradeoffs
    between normal-case runtime performance, and the instrumentation that would be needed
    to simultaneously monitor performance problems.
    Joe
    >
    Thanks,
    Dave

  • Dbms_xmlschema's automatic type generation

    Hi,
    I would like to import XML documents in Oracle 9i Release 2 which contain a structure like this:
    <TEST>
    <TEST/>
    <TEST/>
    </TEST>
    I am using the following schema definition:
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    elementFormDefault="qualified"
    targetNamespace="http://www.informatik.hu-berlin.de/~vitt/test"
    xmlns:t="http://www.informatik.hu-berlin.de/~vitt/test"
    >
    <xs:complexType name="C_TEST">
    <xs:sequence>
    <xs:element minOccurs="0" maxOccurs="unbounded" ref="t:TEST" />
    </xs:sequence>
    </xs:complexType>
    <xs:element name="TEST" type="t:C_TEST"/>
    </xs:schema>
    I am importing this schema using PL/SQL's DBMS_XMLSCHEMA.registerURI with the default options, i.e. automatic type and table generation turned on. Unfortunately, this does not quite work as expected. If I ask SQL*Plus to describe the created table, Oracle disconnects:
    SQL> describe TEST4711_TAB
    ERROR:
    ORA-03113: end-of-file on communication channel
    Describing the created types shows that something went wrong:
    SQL> describe C_TEST4710_T
    C_TEST4710_T is NOT FINAL
    Name Null? Type
    SYS_XDBPD$ XDB.XDB$RAW_LIST_T
    TEST REF OF XMLTYPE
    SQL> describe TEST4712_COLL
    TEST4712_COLL VARRAY(2147483647) OF C_TEST4710_T
    TEST4712_COLL is NOT FINAL
    Name Null? Type
    SYS_XDBPD$ XDB.XDB$RAW_LIST_T
    TEST REF OF XMLTYPE
    As far as I understand, the TEST element of C_TEST4710_T should be of the TEST4712_COLL type, not simply a REF OF XMLTYPE, as there may be more than one TEST XML elements inside a TEST element.
    How can I get around this problem?
    TIA,
    Thorsten

    Hi,
    What version of Oracle are you using?9.2.0.1.0
    Have you looked at your server to see if the Oracle
    instance is creating any trace or dump files?The DESCRIBE command mentioned in my original post results in the following written to the alert_lehre.log file:
    Mon Aug 30 16:59:57 2004
    Errors in file /oracle/lehre/admin/lehre/udump/lehre_ora_7673.trc:
    ORA-07445: exception encountered: core dump [qmtAddProperty()+783] [SIGSEGV] [Address not mapped to object] [0x29] [] []
    Currently, I do not have access to the trace file, though.
    Have you tried a different version of SQLplus just to
    see if it does the describe?No. However, I get the same error (and the same alert.log entry) when I try to insert a sample XML file into the table, as well from SQLplus as from a third-party tool using OCI.
    I seem to have found a workaround now -- a slight reformulation of the XML Schema definition appears to make Oracle create a correct type definition:
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    elementFormDefault="qualified"
    targetNamespace="http://www.informatik.hu-berlin.de/~vitt/test"
    xmlns:t="http://www.informatik.hu-berlin.de/~vitt/test"
    >
    <xs:complexType name="C_TEST">
    <xs:sequence>
    <!-- old: <xs:element minOccurs="0" maxOccurs="unbounded" ref="t:TEST" /> -->
    <xs:element minOccurs="0" maxOccurs="unbounded" name="TEST" type="t:C_TEST"/>
    </xs:sequence>
    </xs:complexType>
    <xs:element name="TEST" type="t:C_TEST"/>
    </xs:schema>
    SQL> describe C_TEST6847_T;
    C_TEST6847_T is NOT FINAL
    Name Null? Type
    SYS_XDBPD$ XDB.XDB$RAW_LIST_T
    TEST XDB.XDB$XMLTYPE_REF_LIST_T
    -- Thorsten

  • Type 2 JDBC driver

    Does anyone know of a type 2 JDBC driver for MS SQL Server?

    Hi,
    Does this help at all?
    http://industry.java.sun.com/products/jdbc/drivers
    Regards,
    Matt
    Java Developer Technical Support
    Sun Microsystems
    http://www.sun.com/developers/support/

  • What are Automatic type conversion rules ?

    Please list out the rules that govern automatic type conversion.

    Hi Albert,
    Check the SAP help at:
    http://help.sap.com/saphelp_47x200/helpdata/EN/fc/eb3427358411d1829f0000e829fbfe/frameset.htm
    Regards,
    Arjan

  • What is the driver type for  jdbc:microsoft:sqlserver ?

    Hai
    I am using the DB connection using the following statement.
    jdbc:microsoft:sqlserver://dbservername:1433;databasename=dbname; user=username;password=pwd
    Totally We have 4 types of JDBC driver.
    The jdbc:microsoft:sqlserver comes under which type of JDBC driver, Can any one please help me....

    How can I differentiate the drivers in my code?Why?
    Can I get some examples from any of the site?http://developers.sun.com/product/jdbc/drivers

  • Type 4 jdbc drivers

    hi
    I want to know that weblogic 7 support type 4 jdbc drivers for oracle
    kindly reply me
    Punee jain

    This isn't a JDBC question. It's a weblogic question.
    I'm sure Bea has some documentation on that on their website
    Thomas

  • How to know which type of jdbc driver used in my application

    How to know which type of jdbc driver used in my application.

    My approach will be....
    Type1: you have to have ODBC s/w install on your machine...even the connection string starts with jdbc:odbc....so it can be identifed easily
    Type2: you have to install client s/w in your machine...if you are using oracle oci driver ...you need to install oracle client s/w
    Type3: you use servername / port to connnect to middleware
    Type4: you do not need any client s/w
    So, If your application works without any client s/w on your machine....you might be using Type4/Type3 driver.....otherwise Type2
    Someone pls add more ....

  • TS4006 My iPhone4 when I try to write a letter automatically type another letter

    My iphone is showing trouble when I trying to write a SMS its automatic type another letter

    Go to settings - general - keyboard - auto-correction turn it off.

  • WebLogic Type 4 JDBC Oracle driver

    can anybody plz tell me from where i can download WebLogic Type 4 JDBC Oracle driver

    Suma wrote:
    can anybody plz tell me from where i can download WebLogic Type 4 JDBC Oracle driverYou can't get our oracle driver as a standalone. It is integrated into the weblogic
    application server. For standalone applications needing a type-4 driver, there is
    Oracle's own, and commercial drivers like DataDirect's.
    Joe

  • Good DB2 type 4 jdbc drivers?

    Hi
    Any recommendation on reliable and good DB2 type 4 jdbc drivers. Thanks
    Jia

    Hi Pat,
    We are using jt400.jar to connect to our AS/400 systems.
    I hope you might have seen , how to configure JDBC drivers document.
    In Communication channel you have to use :
    jdbc:as400://servername/
    Thanks,
    raj.

Maybe you are looking for