Conversion from a string to date type

I am trying for a servlet application , for which the requirement is as under :
from a html form through a input type text field , a date in string format , say 12/25/01 , is picked up.
this date is received in the servlet code , and is required to be updated in Microsoft Access Database Table under a field of data type "Date/Time"
here the problem is , the date's existing data type is String and the Access' field's Data type is Date/Time , therefore, it needs to be suitably converted to a date format before it is put into a sql statement .
please help , if any functionality is available for a conversion .
thanx and regards

yes stephen , taking a tip from you and another from a post from this forum yesterday on SQL Exception , i shifted my focus to java.sql.Date ,
now modifying my code as under works with perfect perfection ,
thanks stephen and joe schell for all the help
kapil
import java.text.*;
import java.sql.Date;
import java.sql.*;
class HardTrial{
     public static void main(String args[]){
          Connection con = null;
          Statement stmt = null;
          ResultSet rs = null;
          Date d = new Date(123456789);// initialising with some value
          Date d1 = d.valueOf("1994-12-12");
          try{
          Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
          con = DriverManager.getConnection("jdbc:odbc:STUDENT_DSN");
          stmt= con.createStatement();
     PreparedStatement ps = con.prepareStatement("INSERT INTO NewTab VALUES (?,?)");
     ps.setDate(1, d1);
ps.setString(2, "TESTING");
ps.executeUpdate();
     rs = stmt.executeQuery("SELECT WHEN,WHAT FROM NewTab");
     while (rs.next()){
     System.out.println(rs.getString("WHEN")+ rs.getString("WHAT"));
     }catch(Exception e){
          System.out.println(e);

Similar Messages

  • Function returning string.  Data type question

    Hello all,
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
    Our database has a parent record master_member_record_id & and children of those records member_record_id. I wrote a function which returns the master record for the child.
    eg. get_master(member_record_id). simple enough.
    I have wrote the opposite of this also, get_member_records(master_member_record_id). Obviously this function has multiple records to return so I have it set to return a listagg string with ',' separation. They want to be able to use this function as follows:
    select * from member_table where member_record_id in (get_member_records(master_member_record_id));
    or something similar, I realize this is a data type issue here, wondering if this is even possible. What do you think?
    Thanks in advance for your criticism/help,
    Chris

    My disagreement is with how pipeline table functionality is used.
    Instead of this (what it sounds like the OP is doing but returning CSV format)
    create or replace type TClientIdArray is table of number;
    create or replace function GetClientIDs( parentID number ) return TClientIdArray is
      array TClientIdArray;
    begin
      select
        client_id bulk collect into array
      from master_table
      where parent_id = parentID;
      return( array );
    end;A pipeline would look as follows:
    create or replace type TClientIdArray is table of number;
    create or replace function GetClientIDs( parentID number ) return TClientIdArray pipelined is
    begin
      for c in (select
                   client_id
                 from master_table
                 where parent_id = parentID ) loop
        pipe row( c.client_id );
      end loop;
      return;
    end;The first method is in fact more sensible in this case, especially when used from PL/SQL. A single SQL call/context switch to get a list of client identifiers. The issues with the first method are
    - cannot effectively deal with a large data set of client identifiers
    - would be suboptimal to use this function in subsequent SQL
    - if called by a client, a ref cursor (not collection) should be returned
    But assuming that the list of client identifiers are needed to be stepped through via complex PL/SQL app processing, using a (small) array is fine (assuming that concurrency/locking is not needed via a FOR UPDATE on the select that identifies the client identifiers to process).
    A pipeline in this case does not do anything better. It introduces more moving parts - as a native PL/SQL can no longer be used to get the collection and step through it. A TABLE() SQL function is needed, a SQL statement, and more context switching.
    The pipeline is simply an unnecessary layer between the code wanting to use the client identifiers and the SQL statement supplying the client identifiers. This approach of SQL -calls-> PIPELINE -calls-> MORE SQL is invariable wrong - unless the pipeline (PL/SQL code) does something very funky with the data from its SQL call, prior to piping it, that cannot be done using SQL.
    If the "user" of that client identifiers is SQL code, then both the above methods are flawed. As this code is already SQL, why use PL/SQL to call more SQL code? Simply use the SQL code/logic that supplies the client identifier list directly in the SQL code that needs the client identifiers. This means something like SQL JOIN, EXISTS, or IN clauses.

  • JCo getting truncated value from SAP when field data type is RAW

    We are trying to fetch data from a SAP-AII table by using JCo using the RFC RFC_READ_TABLE.
    We are getting incomplete data when the data type of the column is RAW in a particular table.A typical case is:
    Table Name: /AIN/DM_DEVCTR
    Field : CLIENT                Type: CLNT    Length:3      Value: 100                                                            (SAP Generated)
    Field:  DEVCTR_GUID    Type:RAW      Length:16    Value: 306F50F53805ED488DE9797AC86B5728     (SAP Generated)
    Filed:  DEVCTR_ID         Type:CHAR    Length:128   Value: KDEVICECONTROLLER                             (User input)
    For the fields CLIENT and DEVCTR_ID we get the entire value (including blank spaces) but for DEVCTR_GUID we get only 16 characters whereas SAP-AII stores a value that is 32 characters in length. How do we fetch the actual value instead of the truncated value?
    Sample code is attached.
              try {
                   mConnection = JCO.createClient("100", // SAP client
                             "User", // userid
                             "Password", // password
                             "EN", // language
                             "SAP", // host name
                             "00"); // system number
                   mConnection.connect();
                   if (mConnection == null) {
                        System.out.println("Connection to SAP Server failed.");
                   mRepository = new JCO.Repository("User", mConnection);
                   ftemplate = mRepository.getFunctionTemplate("RFC_READ_TABLE");
              } catch (Exception ex) {
                   ex.printStackTrace();
                   System.exit(1);
              JCO.Function function = ftemplate.getFunction();
              JCO.ParameterList importParamList = function.getImportParameterList();
              importParamList.setValue("/AIN/DM_DEVCTR", "QUERY_TABLE");
              importParamList.setValue(";", "DELIMITER");
              JCO.Table tableData = function.getTableParameterList().getTable("DATA");
              JCO.Table fields = function.getTableParameterList().getTable("FIELDS");
              mConnection.execute(function);
              if (tableData.getNumRows() > 0) {
                   do {
                        for (JCO.FieldIterator e = tableData.fields(); e
                                  .hasMoreElements();) {
                             JCO.Field field = e.nextField();
                             String str = field.getString();
                             String[] values = str.split(";");
                             for(int i = 0; i < values.length; i++){
                                  System.out.println(values<i>);
                   } while (tableData.nextRow());
              } else {
                   System.out.println("No results found");
              mConnection.disconnect();

    Hi Kaanu,
       You have to modify your java code.
    String val = new String( field.getByteArray());
    PS: Please reward points for helpful answer or problem resolved.

  • Conversion from YYYYMMDD to Julian Date in BPEL

    Hi,
    My requirement is to convert date format from YYYYMMDD to Julian Date (CYYDDD) in BPEL.
    C - Stands for Century
    Would like to know a way to achieve this conversion in BPEL. Please suggest.
    Appreciate your quick help.
    Thanks
    Priyanka G

    Hi,
    I suggest you use a java activity for that... There are many examples in java on how to convert a date to julian...
    Cheers,
    Vlad

  • How to display image from wamp if the data type i use is blob?

    please help me with the problem of displaying image from wamp if data type is blob. Thanks

    Don't store the images in the database. Store the image file names in the database and put the images in a folder.

  • Change "String" into data type "Date"

    Hi,
    I have created a report containing several date fields for a plan/actual comparison. The connection is built up by using the jdbc connector.
    My problem is that the date fields are only displayed as String, but I actually want them to be displayed as Date type.
    Here an example:
    Right now the date fields are displayed like this "20060411"
    but I want them to be displayed like this ("11/04/2006", or similar).
    I would appreciate any suggestions to solve this problem!
    Cheers
    Thomas

    Hi Thomas,
    Check out the following links :
    http://help.sap.com/saphelp_nw04/helpdata/en/55/55a34098022a54e10000000a1550b0/content.htm
    http://help.sap.com/download/netweaver/nw04/visualcomposer/VC_60_UserGuide_v1_1.pdf
    Re: Custom message in VC
    Thanks in advance,
    Deep.

  • Is string primitive data type?

    - Is String a primitive date type? Elaborate please.
    - How is String object is mutable?

    > It is completely immutable. Once created it cannot be changed.
    import java.lang.reflect.*;
    public class ImmutableStringDemo {
        public static void main(String[] args) throws Exception {
            String string = "foo";
            System.out.println(string);
            new StringChanger().change(string);
            System.out.println(string);
    class StringChanger {
        public void change(String s) throws IllegalAccessException {
            Field[] fields = s.getClass().getDeclaredFields();
            for (Field f : fields) {
                f.setAccessible(true);
                if (f.getType() == char[].class) {
                    f.set(s, "bar".toCharArray());
    }QED. ;o)
    ~

  • WAS 6.20: Why does WSDL generated from BAPI includes the data type BCD3.0?

    Hello,
    I'm trying to invoke a BAPI (specifically BAPI_REQUISITION_GETDETAIL) via WAS 6.20 however the WSDL that's returned from the Web Service Browser contains the following Schema:
    <xsd:element name="GR_PR_TIME" minOccurs="0" type="xsd:bcd3.0"/>
    The xsd namespace prefix is defined as follows:
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    .NET is complaining about this data type with the following parser error:
    Schema parsing error Type 'http://www.w3.org/2001/XMLSchema:bcd3.0' is not declared.
    and as far as I can tell binary coded decimal (bcd) isn't part of the Schema specification.
    Can anyone shed any insight as to why serialization is occurring this way and if there's anyway to correct or work around it?
    Thanks,
    Jay
    Where

    your noise margin increasing from 6 to 9 after you previously had it reset is a good indication there is a problem
    did you try thr quiet line test?
    are you connected directly to the master or test socket?   do you have other sockets apart from the master?
    you can try this post for other ideas 
    http://community.bt.com/t5/BB-in-Home/Poor-Broadband-speed/m-p/14217#M8397
    If you like a post, or want to say thanks for a helpful answer, please click on the Ratings star on the left-hand side of the post.
    If someone answers your question correctly please let other members know by clicking on ’Mark as Accepted Solution’.

  • Returned data from database field having data type CLOB

    hi..
    i hv table having CLOB field type ... having 12000 char length ... data is present in the field... but when i do select on that field it only returns the limited data from that field for any given row...
    pls let me know wuts may b the problem...
    cheeerrss..

    Are you running the select from SQL*Plus? If so check out the [SET LONG|http://download.oracle.com/docs/cd/B19306_01/server.102/b14357/ch12040.htm#sthref2800] parameter.
    HTH!

  • Conversion from scaled ton unscaled data using Graph Acquired Binary Data

    Hello !
    I want to acquire temperature with a pyrometer using a PCI 6220 (analog input (0-5V)). I'd like to use the VI
    Cont Acq&Graph Voltage-To File(Binary) to write the data into a file and the VI Graph Acquired Binary Data to read it and analyze it. But in this VI, I didn't understand well the functionnement of "Convert unscaled to scaled data", I know it takes informations in the header to scale the data but how ?
    My card will give me back a voltage, but how can I transform it into temperature ? Can I configure this somewhere, and then the "Convert unscaled to scaled data" will do it, or should I do this myself with a formula ?
    Thanks.

    Nanie, I've used these example extensively and I think I can help. Incidently, there is actually a bug in the examples, but I will start a new thread to discuss this (I haven't written the post yet, but it will be under "Bug in Graph Acquired Binary Data.vi:create header.vi Example" when I do get around to posting it). Anyway, to address your questions about the scaling. I've included an image of the block diagram of Convert Unscaled to Scaled.vi for reference.
    To start, the PCI-6220 has a 16bit resolution. That means that the range (±10V for example) is broken down into 2^16 (65536) steps, or steps of ~0.3mV (20V/65536) in this example. When the data is acquired, it is read as the number of steps (an integer) and that is how you are saving it. In general it takes less space to store integers than real numbers. In this case you are storing the results in I16's (2 bytes/value) instead of SGL's or DBL's (4 or 8 bytes/value respectively).
    To convert the integer to a scaled value (either volts, or some other engineering unit) you need to scale it. In the situation where you have a linear transfer function (scaled = offset + multiplier * unscaled) which is a 1st order polynomial it's pretty straight forward. The Convert Unscaled to Scaled.vi handles the more general case of scaling by an nth order polynomial (a0*x^0+a1*x^1+a2*x^2+...+an*x^n). A linear transfer function has two coefficients: a0 is the offset, and a1 is the multiplier, the rest of the a's are zero.
    When you use the Cont Acq&Graph Voltage-To File(Binary).vi to save your data, a header is created which contains the scaling coefficients stored in an array. When you read the file with Graph Acquired Binary Data.vi those scaling coefficients are read in and converted to a two dimensional array called Header Information that looks like this:
    ch0 sample rate, ch0 a0, ch0 a1, ch0 a2,..., ch0 an
    ch1 sample rate, ch1 a0, ch1 a1, ch1 a2,..., ch1 an
    ch2 sample rate, ch2 a0, ch2 a1, ch2 a2,..., ch2 an
    The array then gets transposed before continuing.
    This transposed array, and the unscaled data are passed into Convert Unscaled to Scaled.vi. I am probably just now getting to your question, but hopefully the background makes the rest of this simple. The Header Information array gets split up with the sample rates (the first row in the transposed array), the offsets (the second row), and all the rest of the gains entering the for loops separately. The sample rate sets the dt for the channel, the offset is used to intialize the scaled data array, and the gains are used to multiply the unscaled data. With a linear transfer function, there will only by one gain for each channel. The clever part of this design is that nothing has to be changed to handle non-linear polynomial transfer functions.
    I normally just convert everything to volts and then manually scale from there if I want to convert to engineering units. I suspect that if you use the express vi's (or configure the task using Create DAQmx Task in the Data Neighborhood of MAX) to configure a channel for temperature measurement, the required scaling coefficients will be incorporated into the Header Information array automatically when the data is saved and you won't have to do anything manually other than selecting the appropriate task when configuring your acquisition.
    Hope this answers your questions.
    ChrisMessage Edited by C. Minnella on 04-15-2005 02:42 PM
    Attachments:
    Convert Unscaled to Scaled.jpg ‏81 KB

  • Conversion from hex string to bytes withh out ascii

    how to convert hex string to byte numbers without ascii codes,then all the converted bytes should come into a packets

    rajkumar5 wrote:
    how to convert hex string to byte numbers without ascii codes,then all the converted bytes should come into a packets
    What people consider ASCII and Hex with strings varies so much, you pretty much need to supply an example.  The best way is to create a VI with default data in the string control and indicator (to show what you want out).

  • How do i get something from keyboard into primitive data type such as int

    Hi guys,
    How do i store a value that was accepted via keyboard into a int variable.
    The method i tried to use was readInt of DataInputStream class which allows me enter some number then enter some number again and when i print the value stored in the variable, which is suppose to be what i entered, it prints a junk number.

    import java.io.*;
    public class Read {
         public static void main( String [] args ) throws Exception {
              BufferedReader br = new BufferedReader( new InputStreamReader( System.in ) );
              System.out.print( "Integer: " );
              String integer = br.readLine();
              int i = Integer.parseInt( integer );
              System.out.println( "i = " + i );
              br.close();
    }

  • Convert from String data type to Character data type

    Hi...,
    I'm a beginner. I try to make a program. But I don't know how to convert from string to data type. I try to make a calculator with GUI window. And when somebody put "+" to one of the window, I just want to convert it to Character instead of String.
    Sorry of my bad english..
    Please help me....
    Thanks

    String s = "a+b";
    char theplus = s.charAt(1);

  • SSIS Package : While Extracting Sharepoint Lookup column, getting error 'Cannnot convert between unicode and non-unicode string data types'

    Hello,
    I am working on one project and there is need to extract Sharepoint list data and import them to SQL Server table. I have few lookup columns in the list.
    Steps in my Data Flow :
    Sharepoint List Source
    Derived Column
    its formula : SUBSTRING([BusinessUnit],FINDSTRING([BusinessUnit],"#",1)+1,LEN([BusinessUnit])-FINDSTRING([BusinessUnit],"#",1))
    Data Conversion
    OLE DB Destination
    But I am getting the error of not converting between unicode and non-unicode string data types.
    I am not sure what I am missing here.
    In Data Conversion, what should be the Data Type for the Look up column?
    Please suggest here.
    Thank you,
    Mittal.

    You have a data conversion transformation.  Now, in the destination are you assigning the results of the derived column transformation or the data conversion transformation.  To avoid this error you need use the data conversion output.
    You can eliminate the need for the data conversion with the following in the derived column (creating a new column):
    (DT_STR,100,1252)(SUBSTRING([BusinessUnit],FINDSTRING([BusinessUnit],"#",1)+1,LEN([BusinessUnit])-FINDSTRING([BusinessUnit],"#",1)))
    The 100 is the length and 1252 is the code page (I almost always use 1252) for interpreting the string.
    Russel Loski, MCT, MCSE Data Platform/Business Intelligence. Twitter: @sqlmovers; blog: www.sqlmovers.com

  • Conversion from milliseconds to Date in 1.5

    A java.util.Date object can be constructed by passing the number of milliseconds since 1 January 1970 as a constructor argument. This Date can then be formatted to a human-readable format with SimpleDateFormat.
    I have tested this conversion from milliseconds to a date both in Java SDK 1.4.1 and Java 1.5.0 to see if there are differences in the way dates are calculated from milliseconds. It seems that there are differences when the system timezone is set to Europe/Berlin. The dates from 1.5.0 are one hour ahead of those from 1.4.1 in a certain week in May 1945 and a day in September 1945.
    This means that milliseconds that are generated from a date by using the Java 1.4.1 runtime and then stored are interpreted differently when they are retrieved when using java runtime 1.5.0, if they happen to be one of those days in 1945. This could cause discrepancies when an application is migrated to JDK 1.5.0.
    This is only a minor problem, but is there any way to know what caused these changes in SDK 1.5.0 and what these changes are? Is there historical data that the Sun implementation is based on to calculate dates from millisecond values?
    Any help is appreciated.
    Kind regards

    I found the following at "http://thedailywtf.com/forums/70146/ShowPost.aspx"
    In summer 1945, Berlin and the Soviet-occupied part of Germany observed a daylight savings time of two hours. Unfortunately, Sun's JRE 1.4 implementation of GregorianCalendar defines a maximum DST of one hour and, in non-lenient mode, rejects the 2 hours as invalid when recalculating all fields after the millisecond field is set.
    Here's the bug report: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4639407

Maybe you are looking for

  • Mail keeps populating server info

    Okay, I want to reinstall Mail... wipe the cobwebs out and freshly enter information.  Problem is, it keeps repopulating the information from somewhere before I have a chance to set it up.  I deleted the mail folder in the Library, the mail preferenc

  • Download movie from iTunes can't stop or pause.???

    I have been downloaded the movie from itunes store, but i realy disappointed when i try to pause or stop the download. Everytime i want to resume download the movie, it start again from the beginning. How to solve this problem? Can i get the refund?

  • Iphoto Stream does not take in concideration the time zone. How to add a certain amount of hours on a Stream automaticly downloaded into Iphoto?

    Hi, I am just back from my holidays with few friends... We were in a Time Zone +6. I have created a Photo stream for everyone to share their photo on the same place. It worked. Back @ my place, I downloaded those photos localy on my laptop to be able

  • How do I disable auto-brightness in my MAC?

    Since I upgraded to Mountain Lion (I skipped Lion), my Mac keeps auto ajdusting the brightness, like every second. The only thing that stops it is pointing it directly at the light bulb, up high. But then it stays at the lowest brightness of this adj

  • Deleting text on path problem

    I am trying to change a text path back to a regular path in ID, but the 'Delete Type from Path' option in the Tpye menu is greyed out. I have tried everything I can think of (i.e. removing stroke/fill/rounded corners, copying part or all of the path)