Conversion from sql date

hi
Am not getting the date in the correct format . Even though teh DB returns me 24-Nov-2008 in java am able to getonly as 0008-11-24
cstmt = this.getConnection().prepareCall("{call scheme_header.p_scheme_dates(?)}");
                    cstmt.registerOutParameter("out_capacity_date", java.sql.Types.DATE);
                    System.out.println("Callalbe stemt " + cstmt);
                    cstmt.execute();
                    Calendar cal = Calendar.getInstance();
                    System.out.println("Calendar " + cal);
                    Date dateObj = cstmt.getDate("out_capacity_date");
                    System.out.println("Dateobj " + dateObj);

Annamala wrote:
The things is am not at all gettign the date in correct format from teh DB .Even though the db gives me the corect date when executed with SQL queryI know that. The thing you don't understand, though, is that you use SimpleDateFormat to change that.
Once again, a Date does not have a format. You use SimpleDateFormat to give the String representation (i.e. the human readable print) of the Date a format when you display it.
java.sql.Date date = new java.sql.Date(System.currentTimeMillis());
System.out.println(date);
// will produce 2008-11-18
SimpleDateFormat sdf = new SimpleDateFormat("dd MMM yyyy");
System.out.println(sdf.format(date));
// will produce 18 Nov 2008
System.out.println(date);
// will still produce 2008-11-18

Similar Messages

  • New To Oracle.. Needs Help:: Conversion from SQL Server to Oracle 11g

    I am new to Oracle 11g and badly need the conversion of SQL Server Functions to Oracle.. Sample Pasted Code not working .. end with error.. pls help
    Create Table TempT (ID1 Varchar (10),
    ID2 Varchar (10)
    CREATE OR REPLACE PACKAGE GLOBALPKG
    AS
    TYPE RCT1 IS REF CURSOR;
    TRANCOUNT INTEGER := 0;
    IDENTITY INTEGER;
    END;
    CREATE OR REPLACE FUNCTION fTempT
    i IN VARCHAR2 DEFAULT NULL
    RETURN GLOBALPKG.RCT1
    IS
    REFCURSOR GLOBALPKG.RCT1;
    BEGIN
    OPEN REFCURSOR FOR
    SELECT TT.*
    FROM TempT TT
    WHERE (fTempT.i = ''
    OR TT.ID1 = fTempT.i)
    RETURN REFCURSOR;
    END;
    CREATE OR REPLACE FUNCTION fTempTF
    i IN VARCHAR2 DEFAULT NULL
    RETURN GLOBALPKG.RCT1
    IS
    REFCURSOR GLOBALPKG.RCT1;
    BEGIN
    OPEN REFCURSOR FOR
    SELECT *
    FROM TABLE(fTempT(i))
    RETURN REFCURSOR;
    END;
    LAST FUNCTION ENDs WITH ERROR
    Error(13,7): PL/SQL: ORA-22905: cannot access rows from a non-nested table item

    2. The major purpose is to get a simplest way to create a parameterized function who can return a table like output. 2nd function has no use instead i was testing the result of First Function like thisIf you just want to select from a select, you should use a view not a function.
    1. which program is more help ful for writing and executing queries bcoz after using Query Analyzer of Microsoft It seems difficult to work on SQL Developer.
    sqlplus? If you are having difficulty learning new tools because of an old one you used, probably best to forget the old one and concentrate on learning the new one because it will be different. This goes for the database itself also.
    2. Can DMLs be used within a Function.Yes, you just can't execute the function in another SQL statement if it modifies data and this is a good thing.
    3. Can temporary tables be used within a function.Unfortunately yes, but they shouldn't be unless you are in a slowest application competition.
    5. Each Function which is a Table Function must be accompanied with Type Definitions?? its a bit longer way of doing the things than SQL ServerThat is why it is better to use views instead, is there any reason you want a select that you can select from inside a function?
    SQL Server for last 9 years thats why i refer this toolThat is not in itself a problem, if you try and do what you did in SQLServer in Oracle, that will be a problem though.

  • PDF from SQL data

    I'm looking for a technology that will help me create multiple formats of similar data from an SQL database into PDFs. I haven't found a sales rep at Adobe who knows if any of their products can do what I need and they recommended the user-to-user forums.
    My web-based application will generate financial affidavits. I need a different template for each state, so I need to create these templates without getting too much into the code itself. The templates will need to draw similar data about assets, liabilities, income and expenses from my SQL database, but the data will be organized in different places on the end document depending on the state. Each state's template (some states have different formats for each county) will also have different fonts, borders, and labels, so I want to be able to create these templates easily, without getting into the code.
    Do you know of any Adobe or other technology that can help me do this?

    I need help on this same subject.   I am being provided with PDF's from SQL (not sure what software).  A 3000 page PDF comes out to 300mb, and if you open it and save as in Adobe Pro, it takes 10 hrs to consolidate fonts and images, but I then end up with a nice 30mb file.   Even using batch PDF conversion software, it takes 5hrs on a good dedicated machine to flatten these PDF's.  I'm guessing it has a lot to do with how they are handling font embedding and the image (form flash) on each page (same on all pages for each PDF).   What kind of programs should I be looking at to keep the PDF file sizes manageable and where I can work with the files without it taking 10 hrs to save them.   I print about 120,000 images per month..  We save the images for up to 6 months..   With 300mb files this won't work..

  • Using relational data from SQL data source in Planning and Essbase

    Hi,
    How do I take sample data from a SQL data source and bring it into a Hyperion Planning application? I understand that when creating Planning applications, a link between a relational data source and Essbase must be established, because the relational database holds the metadata while the database outline is stored with Essbase. However, all I am currently able to do is load the data into Planning applicaitons via EAS, where I right-click on the Application database, hit load data, and select from either a .txt file or an excel file. Do I need Oracle Data Integrator? Any help or insight would be greatly appreciated, as well as corrections to any incorrect assumptions I may have made in this post. Thank you.

    When you import your file (Excel or text), you're importing it using a Load Rule in EAS. To load from SQL, you simply create a SQL load rule. You'll load data the exact same way (via EAS), but with a different type of load rule. The load rule will contain the SQL that queries the database. You can preview your data in the load rule the same way you would with a file.
    If your SQL is very complex, I'd recommend creating a view and loading from that view. But otherwise it's pretty straight-forward.
    The only catch is that you need to configure a database connection (to your relational database) on the Essbase server. The Essbase DBA guide will show you how to do this.
    You COULD use ODI, but I tend to only use it for loading metadata.
    Hope this helps,
    - Jake

  • Conversion From SQL Server to Oracle.. Just New pls someone help

    I am new to Oracle 11g and badly need the conversion of SQL Server Functions to Oracle.. Sample Pasted Code not working .. end with error.. pls help
    Create Table TempT (ID1 Varchar (10),
         ID2 Varchar (10)
    CREATE OR REPLACE PACKAGE GLOBALPKG
    AS
         TYPE RCT1 IS REF CURSOR;
         TRANCOUNT INTEGER := 0;
         IDENTITY INTEGER;
    END;
    CREATE OR REPLACE FUNCTION fTempT
         i IN      VARCHAR2 DEFAULT NULL
    RETURN GLOBALPKG.RCT1
    IS
    REFCURSOR      GLOBALPKG.RCT1;
    BEGIN
    OPEN REFCURSOR FOR
         SELECT TT.*
    FROM TempT TT
    WHERE     (fTempT.i = ''
    OR     TT.ID1 = fTempT.i)
    RETURN REFCURSOR;
    END;
    CREATE OR REPLACE FUNCTION fTempTF
         i IN      VARCHAR2 DEFAULT NULL
    RETURN GLOBALPKG.RCT1
    IS
    REFCURSOR      GLOBALPKG.RCT1;
    BEGIN
    OPEN REFCURSOR FOR
         SELECT *
    FROM TABLE(fTempT(i))
    RETURN REFCURSOR;
    END;
    LAST FUNCTION ENDs WITH ERROR
    Error(13,7): PL/SQL: ORA-22905: cannot access rows from a non-nested table item

    I assume this is a simplified version of a more complex problem, since your second function would not return anything more than the first. If you want to use TABLE on a ref cursor, then you need to do some sort of intermediary transformation, such as using a pipelined function, as in the example in the link below. Also, this does not appear to have anything to do with objects, so should be posted in the SQL and PL/SQL forum instead.
    http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28370/tuning.htm#BABHAABE

  • Conversion from SQL Server 7.0 to Oracle 8 -- Urgent!!

    Hi!
    I've an urgent task of migrating data from SQL Server 7.0 to
    Oracle 8 for Oracle Financials Application. When is the
    Migration Workbench for SQL Server 7.0 is going to be released,
    please let me know?
    And the other question is -- Is there a possiblity that only few
    tables from the legacy system can be migrated into Oracle 8? and
    if yes, how -- details please?
    Thanks,
    Neeta.
    null

    Neeta Singh (guest) wrote:
    : Hi!
    : I've an urgent task of migrating data from SQL Server 7.0 to
    : Oracle 8 for Oracle Financials Application. When is the
    : Migration Workbench for SQL Server 7.0 is going to be released,
    : please let me know?
    : And the other question is -- Is there a possiblity that only
    few
    : tables from the legacy system can be migrated into Oracle 8?
    and
    : if yes, how -- details please?
    : Thanks,
    : Neeta.
    We plan on having a beta version of this capability in early
    August. Contact [email protected] if you want to register as
    a Beta tester.
    Yes, you can update the Oracle model in OMW to remove those
    tables you are not interested in, you can also select to just
    migrate tables & data and nothing else.
    Donal
    null

  • SQL Interface - Error in Loading the data from SQL data source

    Hello,
    We have been using SQl data source for loading the dimensions and the data for so many years. Even using Essbase 11.1.1.0, it's been quite a while (more than one year). For the past few days,we are getting the below error when trying to load the data.
    [Mon Jan 10 11:02:56 2011]Local/{App Name}/{DB Name}/{User Id}/Info(1021013)
    ODBC Layer Error: [S1000] ==> [[DataDirect][ODBC DB2 Wire Protocol driver][UDB DB2 for Windows, UNIX, and Linux]CURSOR IDENTIFIED IN FETCH OR CLOSE STATEMENT
    IS NOT OPEN (DIAG INFO: ).]
    [Mon Jan 10 11:02:56 2011]Local/{App Name}/{DB Name}/{User Id}/Info(1021014)
    ODBC Layer Error: Native Error code [4294966795]
    [Mon Jan 10 11:02:56 2011]Local/{App Name}/{DB Name}/{User Id}/Error(1021001)
    Failed to Establish Connection With SQL Database Server. See log for more information
    [Mon Jan 10 11:02:56 2011]Local/{App Name}/{DB Name}/{User Id}/Error(1003050)
    Data Load Transaction Aborted With Error [7]
    [Mon Jan 10 11:02:56 2011]Local/{App Name}///Info(1013214)
    Clear Active on User [Olapadm] Instance [1]
    Interestingly, after the job fails thru our batch scheduler environment, when I run the same script that's being used in the batch scheduler, the job completes successfully.
    Also, this is first time, I saw this kind of error message.
    Appreciate any help or any suggestions to find a resolution. Thanks,

    Hii Priya,
    The reasons may be the file is open, the format/flatfile structure is not correct, the mapping/transfer structure may not be correct, presence of invalid characters/data inconsistency in the file, etc.
    Check if the flatfile in .CSV format.
    You have to save it in .CSV format for the flatfile loading to work.
    Also check the connection issues between source system and BW or sometimes may be due to inactive update rules.
    Refer
    error 1
    Find out the actual reason and let us know.
    Hope this helps.
    Regards,
    Raghu.

  • Conversion from SQL 2005 to SQL 2012 Express

    Looking to move a small database from SQL 2005 to SQL 2012 Express - can a 2005 backup file be restored to a newly created 2012 Express database file?

    Are you using 2005 express? Yes, you can do that
    http://technet.microsoft.com/en-us/library/ms177429.aspx
    Note that if you restore a SQL Server 2005 or SQL Server 2008 database to SQL Server 2012, the database is automatically
    upgraded. 
    Also you
    cannot
    do a  cross
    edition restore i.e. from enterprise edition (2005) backup to 2012 express
    Satheesh
    My Blog

  • Conversion from raw data tiff format

    Hi,
    I am working on badi "EBPP_INVOICEDETAIL" ,there are two implementation available.
    FM "APAR_EBPP_GET_SDINVOICE_DETAIL"  is called inside the method "GET_INVOICE_DETAIL" ,
    This FM is providing a PDF file for billing document,
    I have a reqd for a new implementation and using a copy of the FM to get a TIF file for billing instead of the PDF.
    Could some one please provide me the logic for doing so, OR
    The FM to convert from raw data to tiff format.
    Regards
    Bidyut

    SQL> select utl_raw.cast_to_number(hextoraw('C20221')), to_number(rawtohex(hextoraw('C20221')), 'xxxxxxxxx') from dual;
    UTL_RAW.CAST_TO_NUMBER(HEXTORAW('C20221')) TO_NUMBER(RAWTOHEX(HEXTORAW('C20221')),'XXXXXXXXX')
                                           132                                            12714529

  • Generate ER Diagram from Sql Data Modeler

    Hi,
    I want to use the Oracle Sql Developer Data Modeler to generate ER diagram for my schema. There are huge number of tables in this schema, so I would like to identify only those tables which need to be selected for generating my ER diagram.
    Basically, I want only those table which are having relationship with other tables here. The reason being, if I select all tables in the schema then I would get those tables in the ER diagram which don't have any relationship with other tables.
    Can someone please suggest writing queries which yield this from data dictionary?
    Thanks.

    Well, your requirement is based on the the database schemas having been designed with proper primary key and foreign key constraints in place.  If they're not there then the database doesn't know about the relationships between tables, and such relationships are just theoretical (and as such usually controlled by the application that uses them).
    Of course there are also tables that are used by applications for lookups and other reasons, so they're part of the application and should be included on ER diagrams, even if they have no direct relationship to any one table (or they could have relationships to many tables).
    So, rather than try and write queries to figure out what tables are required, why not let the Data Modeller tool generate an ER diagram from the information that IS known about on the database, and then you can see if the relationships exist, or if they're missing and need manually putting on the diagram (or applying to the database).

  • Conversion from SQL Server Stored Procedures to Oracle Procedures

    We are having an ERP Package which runs on SQL Server 7.0. For the Reports and Transaction windows, we are using the stored procedures extensively.Now , we want to convert it to Oracle Procedures.Where can i find the resource for this subject.
    Please mail me to [email protected]
    Regards,
    Buhari

    Oracle provides a tool, called the Migration Workbench, that can do an automated conversion. In the newest release of SQL Developer, Oracle's PL/SQL development GUI, the Migration Workbench is built in.
    Be aware, though, that there are limits to what an automated tool is capable of doing. In all probability, you'll want to manually adjust at least a handful of the procedures after any automated tool converts them in order to make things more efficient or to adjust logic that may depend on database-specific behavior. If you have code, for example, that assumes that writers block readers, that code will no longer block in Oracle, which might require re-assessing your algorithm. In addition, there are numerous approaches to developing procedures that are very common in SQL Server (the use of temp tables, for example), that while possible in Oracle generally aren't the most efficient approach.
    Justin

  • How can I get a date without the hour from sql server 2000 ?

    hellou!
    I have a JTable, and one of it's columns has to show a date. This date i have to show is specified as datetime on the Sql Server 2000 database where I have to take the data.
    the query of the dataset attached to the JTable is something like "select * from Table".
    The problem is that the JTable column that displays the date shows the date and the hour, for example:
    7/10/04 0:00:00
    and I need to show the date without the hour, only the 7/10/04. Can anyone tell me how to do that?
    thank you very much! : )

    The easiest way to format a date is with java.text.SimpleDateFormat. When creating it you pass a format string which can be used to parse or format date objects.
    SimpleDateFormat formater = new SimpleDateFormat( "MM/dd/yyyy" );
    // Get date objects directly from sql
    Date foundDate = result.getDate( 1 );  //where result is the ResultSet and 1 is the date column
    String formatedDate = formater.format( foundDate );Now the JTable's table model can be adjusted to store a formated String instead of a Date. If for some reason it is required to store the value as a Date overload the table model to return the formated string when getValueAt is called.

  • Mapping SQL data types (especially SMALLINT) to Java classes

    I want to know the reason for a certain pair of exceptions in JDBC�s mapping of SQL data types to Java classes.
    Sun�s web site ( http://java.sun.com/j2se/1.4.2/docs/guide/jdbc/getstart/mapping.html ), Sybase�s site, and other sites contain mappings from SQL data types to Java primitive data types and/or Java classes. On that Sun web page, Section 9.9.1 maps mostly to Java primitive data types, and Section 9.9.3 maps mostly to Java classes. For the SQL data types that map to both primitive data types and classes, the class is typically the wrapper class of the primitive data type. For example, SQL�s DOUBLE data type maps to both the double primitive data type and its wrapper class (Double). However, Section 9.7 of that Sun web page says that there are exceptions for SQL�s TINYINT and SMALLINT. As expected, they map to the byte and short primitive data types, but they map to the Integer class, not the Byte and Short classes (which are the wrapper classes for byte and short). The web page does not state the reason for this pair of exceptions. It seems to me that SMALLINT data would either work for both short and Short or fail for both short and Short. I don�t see why it would work for short but fail for Short (as the web page implies).
    Can anybody think of a reason for the pair of exceptions? Thanks.

    ghs wrote:
    1) If a DBMS deals with the short and byte primitive data types (as the various web pages imply that it does), then why would it not deal with the Short and Byte wrapper classes?As another guess, because conversions get a little weird in java. Or at least they did in the past. As I recall (with not a lot of clarity) it is possible to do something like pass a perfectly valid string value into a short and get an exception. Whereas using Integer and then converting to Short works.
    Keep in mind that these are guesses.
    3) What I really want to know is this: If I use wrapper classes of Short and Byte (instead of Integer), what will be the harmful consequences (IF ANY)? So far, I have done some trivial testing with a Short for a SMALLINT column (I have not yet tried any TINYINT columns), and it seems to be working.I considered it risky to not test all target databases and drivers.
    Obviously testing will reveal problems.
    If you don't want to test then you might want to stick with integers.

  • Essbase administration service. The SQL data access source is greyed out

    Env: EAS 11g Oracle 10g database
    Hi,
    After i tried to install EAS and try to create a rule file, I find out that I am unable to select the datasource from "SQL data sources" field, which has been greyed out. However, I am able to make the connection in another environment that use the same settings. This is a replica of the system.
    1) Is there something with the connection. If yes, what file(s) I need to check and any other things that I need to check. It could be something with the jdbc.ini file perhaps. But when I try to check this ini file, it appears the same with the one that works in the other environment
    kindly need your help
    Rgds,
    Raymond

    To configure data sources on UNIX:
    1.Open the $EPM_ORACLE_HOME/common/ODBC/Merant/x.x/odbc.ini file and add a data source description.
    2.Copy the $EPM_ORACLE_HOME/common/ODBC/Merant/x.x/odbc.ini to $ESSBASEPATH/bin/.odbc.ini.
    3.Create a symbolic link to the $ESSBASEPATH/bin/.odbc.ini from the UNIX user home directory:
    ln -s $EPM_ORACLE_HOME/common/ODBC/Merant/x.x/odbc.ini /home/myfolder/.odbc.ini
    4.Verify that the odbc.ini file in the user home directory matches the odbc.ini file in EPM_ORACLE_HOME/common/ODBC/Merant/x.x.
    If the files do not match, repeat step1 through step3
    The ODBC-64 folder is used when the Linux is a 64 bit.
    Check if these are the steps you followed to create the Data Source.
    The connection to the DSN created can be checked by below steps in Unix..
    [essdev@dshypdev bin]$ pwd
    essdev/hyperion/products/Essbase/eis/server/bin
    [essdev@dshypdev bin]$ ./odbcconfig
    Using the following Environment...
    Env HYPERION_HOME=/essdev/hyperion
    Env TDODBC=. (for Teradata only)
    odbc.ini file name=/essdev/hyperion/common/ODBC-64/Merant/5.2/odbc.ini
    Database Driver Names:
    Db2=/essdev/hyperion/common/ODBC/Merant/5.1/lib/ARdb221.so
    Oracle=/essdev/hyperion/common/ODBC/Merant/5.1/lib/ARora21.so
    Sybase=/essdev/hyperion/common/ODBC/Merant/5.1/lib/ARase21.so
    Informix=/essdev/hyperion/common/ODBC/Merant/5.1/lib/ARifcl21.so
    Teradata=./drivers/tdata.so
    SQL Server=/essdev/hyperion/common/ODBC/Merant/5.1/lib/ARmsss21.so
    ODBC.ini Configuring Utility
    1. List
    2. Add
    3. Delete
    4. Test
    5. Exit
    Select option 4 to test the connection

  • Date difference when converting Calendar date to sql date

    I am trying to convert a Calendar date to sql date. The only problem in the conversion is sql date adds 1 month to the original date. Due to this my query results show different data than what it is suppossed to show.
    Here is my code
    Calendar startDate = Calendar.getInstance();
    startDate.set(2006, 10, 01, 00, 00); // 1-Oct-2006
    return (new java.sql.Date(date.getTimeInMillis()));
    on the last statement it adds a month to original date. So the final date i get is 1-Nov-2006.
    Any solution to this problem?
    Thanks
    Sameer

    Thanks everyone for quick response.
    I have read javadocs many times but that does not
    change the fact that Calendar and Sql date
    interpretation is different.No, it isn't. You are setting the moth to november when you set the month to 10, and november is what java.sql.Date is showing. So where is the difference? You are doing it wrong and that is why you get the wrong month.
    How the f do you think that the calender should know that you want october when you set it to november?
    My application is deployed through web service and
    the clients may access it through any programming
    langague (java, php, ec). Even I am testing it
    through java and php. Still doesn't matter. You need to subtract the month by one if you want to let your user use 1 for january.
    While testing it through java month is different but
    through php its correct.Read the docs.
    Can smoeone please give me the best possibel solution
    to this?see above

Maybe you are looking for

  • Sound Reset on Xserver reset

    This is something that has just recently started happening. Every time I reset my xserver (ctrl-alt-backspace) it puts my sound back to 'default settings' which include everything being muted and some other settings back. I'm not quite sure why it's

  • Do All Zens Not Work Properly With AudioBooks?

    Do all Zens have the same issues with audiobooks? I bought two and they both have the same issues. I bought the second one because the first one wasn't working right. To wit: 1. Regardless of how many bookmarks are made at different locations, recall

  • How to do a trigger with in parameters

    Hi everybody Is there someone who knows how to do a trigger in a table for updating another table?, I want to do a trigger which must have the user name session, I think that the user name must be include like a parameter for update trigger. The user

  • HT5847 Sync Services for MS Outlook 2011 for Blackberry 9790 on OSX 10.9

    please could you advise when sync services will be working successfully with blackberry handhelds 9790. Currently am running OSX Mavericks 10.9 and my BB does not sync contacts or calenders with MS Outlook 2011. Will there be an update released to re

  • File check on boot up?

    I am a first time computer builder, my specs are as follows: MSI|VIA K8T800 K8T NEO-FIS2R Retail ATI RADEON 9800PRO 128M OEM 3000+ ATHLON 64 Retail ZALMAN CNPS7000A-CU DDRAM 512MB 32MX8 PC-3200C2 Corsairx2 1.44MB SONY MPF920 Beige Western Digital 10,