Java - sql format

I am using a java program to retrieve information from Oracle Database.
The valus is stored in a result string and printed to file. I want to pad the number with leading zeros.
sql command: SELECT LPAD(PAS_ID,9,'0') FROM PA_COURSES WHERE PAS_ID = '121345';
This returns the value in the format that I need: 000121345
When attempting to run this statement through java I get:
column not found error.
Does anyone know of a better way to format using java?

Are you using:
String Sql="SELECT LPAD(PAS_ID,9,'0') FROM PA_COURSES WHERE PAS_ID = '121345';".
You should omit the ; in the string.
Try to use :
String sql="SELECT LPAD(PAS_ID,9,'0') FROM PA_COURSES WHERE PAS_ID = '121345'". You should be ok
null

Similar Messages

  • How to convert JAVA.SQL.DATE date in YYYY/MM/DD format into DD/MM/YYYY

    i am using informix database which accepts date value in the form of DATE format......
    the other part of my application takes date from the field in DD/MM/YYYY format...so i have to convert my java.sql.date in YYYY/MM/DD fromat into DD/MM/YYYY fromat of same type before inserting into db......
    but using parse method in SimpleDateFormat class can get the result only in java.util.date format...
    and also using format method can result only in string conversion........

    816399 wrote:
    i am using informix database which accepts date value in the form of DATE format......Huh?
    Maybe you mean Informix (fronted by JDBC) expects date values as java.sql.Date objects?
    the other part of my application takes date from the field in DD/MM/YYYY format...
    so i have to convert my java.sql.date in YYYY/MM/DD format into DD/MM/YYYY format of same type before inserting into db......I am not sure why you are talking about formats here.
    There is no formatting inherent in a java.util.Date object
    nor in a java.sql.Date object.
    but using parse method in SimpleDateFormat class can get the result only in java.util.date format...
    and also using format method can result only in string conversion........You can easily create a java.sql.Date object from a java.util.Date object.
    String s = "31/12/2010";
    java.util.Date ud = new java.text.SimpleDateFormat("dd/MM/yyyy").parse(s);
    java.sql.Date sd = new java.sql.Date(ud.getTime());
    ud = sd; // java.sql.Date extends java.util.Date so no conversion is needed

  • 7000 : null : java.sql.SQLException: ODI-40400: Invalid format description

    Hello all,
    I am getting this following error , when trying to load from files to Oracle (used this link as reference : http://john-goodwin.blogspot.com/2009/06/odi-series-processing-all-files-in.html)
    ODI 11g 11.1.1.6
    Database
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
    PL/SQL Release 11.2.0.2.0 - Production
    CORE     11.2.0.2.0     Production
    TNS for Linux: Version 11.2.0.2.0 - Production
    NLSRTL Version 11.2.0.2.0 - Production
    any help would be greatly appreciated
    7000 : null : java.sql.SQLException: ODI-40400: Invalid format description
    java.sql.SQLException: ODI-40400: Invalid format description
         at com.sunopsis.jdbc.driver.file.impl.metadata.MetaDataExtractor.buildTableDescFromRequestSQLExceptionOnly(MetaDataExtractor.java:479)
         at com.sunopsis.jdbc.driver.file.FilePreparedStatement.buildGenericRow(FilePreparedStatement.java:75)
         at com.sunopsis.jdbc.driver.file.FilePreparedStatement.<init>(FilePreparedStatement.java:57)
         at com.sunopsis.jdbc.driver.file.FileConnection.prepareStatement(FileConnection.java:299)
         at sun.reflect.GeneratedMethodAccessor67.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at oracle.odi.core.datasource.dwgobject.support.OnConnectOnDisconnectDataSourceAdapter$OnDisconnectCommandExecutionHandler.invoke(OnConnectOnDisconnectDataSourceAdapter.java:200)
         at $Proxy2.prepareStatement(Unknown Source)
         at oracle.odi.runtime.agent.execution.sql.SQLCommand.doInitializeStatement(SQLCommand.java:82)
         at oracle.odi.runtime.agent.execution.sql.SQLCommand.getStatement(SQLCommand.java:117)
         at oracle.odi.runtime.agent.execution.sql.SQLCommand.getBatchCommand(SQLCommand.java:329)
         at oracle.odi.runtime.agent.execution.sql.SQLCommand.processRecord(SQLCommand.java:137)
         at oracle.odi.runtime.agent.execution.cmd.TextCommand.processRecord(TextCommand.java:1)
         at oracle.odi.runtime.agent.execution.DataMovementTaskExecutionHandler.handleTask(DataMovementTaskExecutionHandler.java:86)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.processTask(SnpSessTaskSql.java:2913)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java:2625)
         at com.sunopsis.dwg.dbobj.SnpSessStep.treatAttachedTasks(SnpSessStep.java:561)
         at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java:464)
         at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java:2093)
         at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$2.doAction(StartSessRequestProcessor.java:366)
         at oracle.odi.core.persistence.dwgobject.DwgObjectTemplate.execute(DwgObjectTemplate.java:216)
         at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.doProcessStartSessTask(StartSessRequestProcessor.java:300)
         at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.access$0(StartSessRequestProcessor.java:292)
         at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$StartSessTask.doExecute(StartSessRequestProcessor.java:855)
         at oracle.odi.runtime.agent.processor.task.AgentTask.execute(AgentTask.java:126)
         at oracle.odi.runtime.agent.support.DefaultAgentTaskExecutor$2.run(DefaultAgentTaskExecutor.java:83)
         at java.lang.Thread.run(Thread.java:662)Question2:
    I am calling
    OdiStartScen -SCEN_NAME=ALL_FILES -SCEN_VERSION=001 "-ACTIVITIES.CURRFILENAME=#LOADFILE"
    in ODI procedure and when I execute I am getting this following error two
    OdiStartScen -SCEN_NAME=ALL_FILES -SCEN_VERSION=001 "-ACTIVITIES.CURRFILENAME=#LOADFILE"
    Exception getTargetTable("METADATA_DESC") : ODI-15081: There is no Target TableBoth these errors are happening the same procedure with two commands

    Hello,
    I am getting the same error too. I am just trying to load simple (13 columns all number) txt to oracle table. My interface defination doesn't contain any transformation, filter or join.
    7000 : null : java.sql.SQLException: ODI-40400: Invalid format description
    java.sql.SQLException: ODI-40400: Invalid format description
    at com.sunopsis.jdbc.driver.file.impl.metadata.MetaDataExtractor.buildTableDescFromRequestSQLExceptionOnly(MetaDataExtractor.java:479)
    at com.sunopsis.jdbc.driver.file.FilePreparedStatement.<init>(FilePreparedStatement.java:62)
    at com.sunopsis.jdbc.driver.file.FileConnection.prepareStatement(FileConnection.java:299)
    at sun.reflect.GeneratedMethodAccessor66.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at oracle.odi.core.datasource.dwgobject.support.OnConnectOnDisconnectDataSourceAdapter$OnDisconnectCommandExecutionHandler.invoke(OnConnectOnDisconnectDataSourceAdapter.java:200)
    Source Code:
    select
    CITY_ID
    C1_CITY_ID,
    DISTRICT_ID
    C2_DISTRICT_ID,
    TOWNSHIP_ID
    C3_TOWNSHIP_ID,
    VILLAGE_ID
    C4_VILLAGE_ID,
    QUARTER_ID
    C5_QUARTER_ID,
    STREET_ID
    C6_STREET_ID,
    BUILDING_ID
    C7_BUILDING_ID,
    INDEPENDENTSECTION_ID
    C8_INDEPENDENTSECTION_ID,
    MATCH_LEVEL
    C9_MATCH_LEVEL,
    SERIAL_NUM_SEQ
    C10_SERIAL_NUM_SEQ,
    POLICY_NUM
    C11_POLICY_NUM,
    RENEWAL_NUM
    C12_RENEWAL_NUM,
    ADDRESS_NUM
    C13_ADDRESS_NUM
    from
    TABLE
    /*$$SNPS_START_KEYSNP$CRDWG_TABLESNP$CRTABLE_NAME=ADDRESS_HINT_FLSNP$CRLOAD_FILE=C:/temi/adress_hints.txtSNP$CRFILE_FORMAT=DSNP$CRFILE_SEP_FIELD=0x0009SNP$CRFILE_SEP_LINE=0x000D0x000ASNP$CRFILE_FIRST_ROW=1SNP$CRFILE_ENC_FIELD=SNP$CRFILE_DEC_SEP=SNP$CRSNP$CRDWG_COLSNP$CRCOL_NAME=CITY_IDSNP$CRTYPE_NAME=NUMERICSNP$CRORDER=1SNP$CRLINE_OFFSET=1SNP$CRLENGTH=3SNP$CRSCALE=0SNP$CRPRECISION=3SNP$CRSNP$CRDWG_COLSNP$CRCOL_NAME=DISTRICT_IDSNP$CRTYPE_NAME=NUMERICSNP$CRORDER=2SNP$CRLINE_OFFSET=4SNP$CRLENGTH=5SNP$CRSCALE=0SNP$CRPRECISION=5SNP$CRSNP$CRDWG_COLSNP$CRCOL_NAME=TOWNSHIP_IDSNP$CRTYPE_NAME=NUMERICSNP$CRORDER=3SNP$CRLINE_OFFSET=9SNP$CRLENGTH=5SNP$CRSCALE=0SNP$CRPRECISION=5SNP$CRSNP$CRDWG_COLSNP$CRCOL_NAME=VILLAGE_IDSNP$CRTYPE_NAME=NUMERICSNP$CRORDER=4SNP$CRLINE_OFFSET=14SNP$CRLENGTH=10SNP$CRSCALE=0SNP$CRPRECISION=10SNP$CRSNP$CRDWG_COLSNP$CRCOL_NAME=QUARTER_IDSNP$CRTYPE_NAME=NUMERICSNP$CRORDER=5SNP$CRLINE_OFFSET=24SNP$CRLENGTH=10SNP$CRSCALE=0SNP$CRPRECISION=10SNP$CRSNP$CRDWG_COLSNP$CRCOL_NAME=STREET_IDSNP$CRTYPE_NAME=NUMERICSNP$CRORDER=6SNP$CRLINE_OFFSET=34SNP$CRLENGTH=10SNP$CRSCALE=0SNP$CRPRECISION=10SNP$CRSNP$CRDWG_COLSNP$CRCOL_NAME=BUILDING_IDSNP$CRTYPE_NAME=NUMERICSNP$CRORDER=7SNP$CRLINE_OFFSET=44SNP$CRLENGTH=15SNP$CRSCALE=0SNP$CRPRECISION=15SNP$CRSNP$CRDWG_COLSNP$CRCOL_NAME=INDEPENDENTSECTION_IDSNP$CRTYPE_NAME=NUMERICSNP$CRORDER=8SNP$CRLINE_OFFSET=59SNP$CRLENGTH=15SNP$CRSCALE=0SNP$CRPRECISION=15SNP$CRSNP$CRDWG_COLSNP$CRCOL_NAME=MATCH_LEVELSNP$CRTYPE_NAME=NUMERICSNP$CRORDER=9SNP$CRLINE_OFFSET=74SNP$CRLENGTH=2SNP$CRSCALE=0SNP$CRPRECISION=2SNP$CRSNP$CRDWG_COLSNP$CRCOL_NAME=SERIAL_NUM_SEQSNP$CRTYPE_NAME=NUMERICSNP$CRORDER=10SNP$CRLINE_OFFSET=76SNP$CRLENGTH=10SNP$CRSCALE=0SNP$CRPRECISION=10SNP$CRSNP$CRDWG_COLSNP$CRCOL_NAME=POLICY_NUMSNP$CRTYPE_NAME=NUMERICSNP$CRORDER=11SNP$CRLINE_OFFSET=86SNP$CRLENGTH=10SNP$CRSCALE=0SNP$CRPRECISION=10SNP$CRSNP$CRDWG_COLSNP$CRCOL_NAME=RENEWAL_NUMSNP$CRTYPE_NAME=NUMERICSNP$CRORDER=12SNP$CRLINE_OFFSET=96SNP$CRLENGTH=2SNP$CRSCALE=0SNP$CRPRECISION=2SNP$CRSNP$CRDWG_COLSNP$CRCOL_NAME=ADDRESS_NUMSNP$CRTYPE_NAME=NUMERICSNP$CRORDER=13SNP$CRLINE_OFFSET=98SNP$CRLENGTH=20SNP$CRSCALE=0SNP$CRPRECISION=20SNP$CR$$SNPS_END_KEY*/
    Target  Code:
    insert into DASK_DWH.C$_0ADDRESS_HINT
      C1_CITY_ID,
      C2_DISTRICT_ID,
      C3_TOWNSHIP_ID,
      C4_VILLAGE_ID,
      C5_QUARTER_ID,
      C6_STREET_ID,
      C7_BUILDING_ID,
      C8_INDEPENDENTSECTION_ID,
      C9_MATCH_LEVEL,
      C10_SERIAL_NUM_SEQ,
      C11_POLICY_NUM,
      C12_RENEWAL_NUM,
      C13_ADDRESS_NUM
    values
      :C1_CITY_ID,
      :C2_DISTRICT_ID,
      :C3_TOWNSHIP_ID,
      :C4_VILLAGE_ID,
      :C5_QUARTER_ID,
      :C6_STREET_ID,
      :C7_BUILDING_ID,
      :C8_INDEPENDENTSECTION_ID,
      :C9_MATCH_LEVEL,
      :C10_SERIAL_NUM_SEQ,
      :C11_POLICY_NUM,
      :C12_RENEWAL_NUM,
      :C13_ADDRESS_NUM

  • Java.sql.SQLException:ORA-01801:date format is too long for internal buffer

    Hi,
    I am getting the following exception when i trying to insert data in to a table through a stored procedure.
    oracle.apps.fnd.framework.OAException: java.sql.SQLException: ORA-01801: date format is too long for internal buffer
    when execute this stored procedure from ana anonymous block , it gets executed successfully, but i use a OracleCallableStatement to execute the procedure i am getting this error.
    Please let me know how to resolve this error.
    Is this error something to do with the Database Configuration ?
    Thanks & Regards
    Meenal

    I don't know if this will help, but we were getting this error in several of the standard OA framework pages and after much pain and aggravation it was determined that visiting the Sourcing Home Page was changing the timezone. For most pages this just changed the timezone that dates were displayed in, but some had this ORA-01801 error and some others had an ORA-01830 error (date format picture ends before converting entire input string). Unfortunately, if you are not using Sourcing at your site, this probably won't help, but if you are, have a look at patch # 4519817.
    Note that to get the same error, try the following query (I got this error in 9.2.0.5 and 10.1.0.3):
    select to_date('10-Mar-2006', 'DD-Mon-YYYY________________________________________________HH24:MI:SS') from dual;
    It appears that you can't have a date format that is longer than 68 characters.

  • Put java.sql.Date in correct format

    I need to put java.sql.Date in correct format to query an Oracle database.
    Here is my code:
            SimpleDateFormat formatter = new SimpleDateFormat("dd-MMM-yy");
            java.util.Date dateChosen = jXDatePicker1.getDate();
            String strDate = formatter.format(dateChosen);
            System.out.println("Date Chosen: " + strDate); // output is: 11-Feb-00
            java.util.Date parserDate = null;      
            try {
                parserDate = formatter.parse(strDate);
            } catch (ParseException re) {
                System.err.println("Exception caught: " + re.getMessage());
            // create java.sql.Date object
                java.sql.Date oraDate = new java.sql.Date(parserDate.getTime());
            System.out.println(oraDate);  // date is in this format: 2000-02-11
            System.out.println("formatted oraDate: " + formatter.format( oraDate ) ); // no good, stringIf I use formatter.format( oraDate ) I get the correct format (11-Feb-00) BUT it is no longer a sql Date, it is a String which can't be use.
    I have looked at the API and many other forum threads on this, any help would be greatly appreciated!

    In the class with the PreparedStatement, I pass the date like this:
    public class report extends javax.swing.JDialog {
         java.sql.Date newDate;
        public report(java.sql.Date passedOraDate, String passedtxtDate) {
            super();
            initComponents();
            setTitle("Report");
            setModal(true);
            newDate = passedOraDate;
            statusLabel.setText(passedtxtDate);
            System.out.println("passedtxtDate: " +passedtxtDate);       
            System.out.println("newDate: " +newDate);      
        }Here is the code that uses the actual PreparedStatement:
            try {
                // In my actual code I have all columns listed in query
                String query = "SELECT * FROM report WHERE repdate = ?";
                ps = conn.prepareStatement(query); // create a statement
                           ps.setDate(1, newDate); // set input parameter
                rs = ps.executeQuery();
                // extract data from the ResultSet
                ResultSetMetaData md = rs.getMetaData();
                int columns = md.getColumnCount();This is greatly edited to show relevant code!

  • Convert a String to java.sql.Date Format

    Hi,
    I am having a String of containing date in the format 'dd/mm/yyyy' OR 'dd-MMM-YYYY' OR 'mm-dd-yyyy' format. I need to convert the string to java.sql.Date object so that I can perform a query the database for the date field. Can any one suggest me with the code please.
    Regards,
    Smitha

    import java.text.SimpleDateFormat;
    import java.text.ParseException;
    import java.util.Date;
    public class TestDateFormat
         public static void main(String args[])
              SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
              System.out.println(sdf.isLenient());
              try
                   Date d1 = sdf.parse("07-11-2001");
                   System.out.println(d1);
                   Date d2 = sdf.parse("07:11:2001");
                   System.out.println(d2);
              catch(ParseException e)
                   System.out.println("Error format, " + e);
    See class DateFormat and SimpleDateFormat for detail.

  • Converting String foramt(yyyy-mm-dd) to java.sql.Date format(mm/dd/yyyy)

    Hi,
    I am new to this Technology.
    in my Project DataBase I have the date field as String in format yyyy-mm-dd. when I am trying to fetch this date through the front-end I need to see the date in dd/mm/yyyy format of type java.sql.Date Variable.
    if you know, Pl help me.
    Thanks in Advance,
    Kamala.

    Then use a SimpleDateFormat object to parse it into a Date object, and also to format the Date the way you want to see it, rather than simply relying on the toString() implementation.

  • Convert java.sql.date to dd.mm.yyyy format

    Hi,
    Can any one tell me how to convert java.sql.date to dd.mm.yyyy format
    Regards,
    H.V.Swathi

    Hi ,
    Create a simple data type of type java.sql.date and give the format in it as "dd/MM/yyyy". This will work i guess.
    Regards
    Ishita

  • Making java.sql.Date dd.mm.yyyy format

    Hi,
    java.sql.Date format is m/d/yyyy.
    I must use  dd.mm.yyyy format.
    How can it be done?
    Thanks.

    You can use the following line of code to change the date format
    SimpleDateFormat formatter = new SimpleDateFormat("dd.MM.yyyy");
    String formattedDate = formatter.format(<Ur java.sql.Date instance>);
    Edited by: Santhosh Edla on Sep 7, 2009 5:00 PM

  • What is this error java.sql.SQLException: Bad format for number ?

    Dear All,
    I am reading few values from database. Then I get this error "MyError:Error : java.sql.SQLException: Bad format for number 'Sarawak' in column 6. " So what is this error referring to. I have checked the database column and its value fits according the data type. Any hints please?

    I have checked the database column and its value fits according the data type.Check again. Then check again. Keep checking until you find your error. You are trying to read a string containing "Sarawak" as a number. You have "getInt(6)" or other numeric type, and the 6th column in the select statement is not numeric.

  • Needed help regarding converting  string to java.sql.Date format

    I have a a function which returns a calendar object. The date must be inserted to Oracle DB using java.sql.Date format.
    So i have converted the Calendar object to java.sql.Date format using the following code
    java.sql.Date publicationDate = new java.sql.Date(book.getPublicationDate().getTime().getTime());But while getting inserted into the DB it was in mm/dd/yyyy format whereas i wanted dd/mm/yyyy format
    Can any body please help out how to store the date in dd/mm/yyyy format ?

    Can u please explain this a bit
    This is my code
    public int addBook(List<Book> BookList) throws SQLException, ParseException{
              System.out.println("Hi there");
              Book book = new Book();
              BookDB bookDb = new BookDB();
              //listLength =      BookList.length;
              String bookId = null;
                   try{
                        DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
                        con  = DriverManager.getConnection("jdbc:oracle:thin:@10.123.79.195:1521:findb01","e115314", "e115314");
                        addBook = con.prepareStatement("insert into ABC_Book values(?,?,?,?,?,?,?)");
                        Iterator<Book> iterator = BookList.iterator();
                        while(iterator.hasNext()){
                             book = (Book)iterator.next();
                             System.out.println(book.getBookId());
                             addBook.setString(1,book.getBookId());
                             addBook.setString(2,book.getTitle());
                             addBook.setString(3,book.getAuthor());
                             addBook.setString(4,book.getPublisher());
                             System.out.println(book.getPublicationDate());
                             System.out.println("Before Date");
                             System.out.println("book.getPublicationDate().getTime()"+book.getPublicationDate().getTime());
                             java.sql.Date publicationDate = new java.sql.Date(book.getPublicationDate().getTime().getTime());
                             SimpleDateFormat formatter = new SimpleDateFormat("dd/mm/yyyy");
                             dateString = formatter.format(publicationDate);
                             System.out.println("Today is"+dateString);
                             java.sql.Date date = (java.sql.Date)formatter.parse(dateString);
                             System.out.println("date"+date);
                             //java.sql.Date publicationDate = (Date)book.getPublicationDate().getTime();
                             //System.out.println("Value of date is"+publicationDate);
                             System.out.println("After Date");
                             addBook.setDate(5,publicationDate);
                             addBook.setString(6,book.getCountry());
                             addBook.setString(7,book.getLanguage());
                             rs = addBook.executeQuery();
                             //con.commit();
                             rowCount = rowCount + rs.getRow();
                        return rowCount;
                   catch(SQLException se){
                        se.printStackTrace();
                   finally{
                        con.close();
                        System.out.println("After adding ");
              return 0;
         }

  • Poblem with java.sql.Date while inserting to a table

    Hi All,
    I have a PostgreSQL database table which contains fields(columns ) of type date. I want to insert values to the table in the[b] �dd-MMM-YYYY� format using the prepared statement.
    My code is as follows
    java.text.DateFormat dateFormatter =new java.text.SimpleDateFormat("dd-MMM-yyyy");
    String formatedDate=dateFormatter.format(theDate);
    currentDate = new java.sql.Date(dateFormatter.parse(formatedDate).getTime())
    �������������������
    �������������������
    �������������������
    pst.setDate(12,currentDate);The problem is the currentDate variable gives date only in the �YYYY-MMM-dd� format but requirement is the currentDate variable should give date in the �dd-MMM-YYYY� format and this should be save to table as java.sql.Date type
    There is any solution???? please help me...
    Thanks and Regards,
    Hyson_05

    Hi,
    What are you talking about? A Date does always wrap a millisecond value, and doesn't have any formatting. It's the database, or your program which formats the date that you see.
    In short. You should format the value when you print it, and not when you store it.
    Kaj

  • OpenSQLException - object of type java.sql.Date is not normalized

    Hi,
    I am attempting to code an SQL query in an EJB and get the following exception:
    com.sap.sql.log.OpenSQLException: The object of type java.sql.Date with the value '2010-06-04 13:21:09.424' assigned to host variable 1 is not normalized. It must not contain time components in the time zone running the virtual machine. at com.sap.sql.log.Syslog.createAndLogOpenSQLException(Syslog.java:85) at com.sap.sql.log.Syslog.createAndLogOpenSQLException(Syslog.java:124) at com.sap.sql.jdbc.common.CommonPreparedStatement.setDate(CommonPreparedStatement.java:650) at......
    Below is the code snippet I am using:
                        private static String selWQ  = "Select * from ZZZZ_TABLE " +
                                                                       "where DATEFROM >= ? " +
                                                                  "and DATETO <= ? ";
         public UsageRecord[] getRecords(Date fromDate,Date toDate)
              UsageRecord[] ura = null;
              String q          = null;
              ArrayList al      = new ArrayList();
              try
                   q = selWQ;
                   conn.open();
                   PreparedStatement p = conn.prepareStatement(q);               
                   p.setDate(1, fromDate);
                   p.setDate(2,toDate);                    
                   ResultSet rs = p.executeQuery();
    I have a PreparedStatement and am using setDate to set the values. The fromDate and toDate parameters are of type java.sql.Date
    Can someone please tell me what I am doing wrong and how to fix it?
    thanks
    Brian

    As requested, here is an example of what I used to resolve this:
                   PreparedStatement p = conn.prepareStatement(q);
                   SimpleDateFormat ddf = new SimpleDateFormat("yyyy-MM-dd");
                                               String sFrom = ddf.format(new java.util.Date(fromDate));
                   String sTo   = ddf.format(new java.util.Date(toDate));
                   p.setDate(1, java.sql.Date.valueOf(sFrom));
                   p.setDate(2, java.sql.Date.valueOf(sTo));
                   ResultSet rs = p.executeQuery();
    fromDate and toDate are parameters of type long...
    regards
    Brian

  • I am getting Error! java.sql.SQLException:General error

    hi every body,
    I struck with this error , can any one suggest in solving this.
    I had a table in oracledatabase ,i have successfully created a table and inserted clob column with an attachment like xxx.txt.
    table format----> id and text columns
    Now my question is to retrieve that data and store it in local disk i am getting this error
    import java.io.*;
    import java.sql.*;
    //import java.sql.SQLException;
    public class Cread {
    public static void main(String[] args) throws ClassNotFoundException,IOException,SQLException {
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection cn=DriverManager.getConnection("jdbc:odbc:sivadsn","scott","tiger");
    Statement s = cn.createStatement();
    ResultSet rs=s.executeQuery("Select text from ram where id=10");
    if(rs.next()){
    FileOutputStream file=new FileOutputStream("c:/store.txt");
    InputStream fin=rs.getBinaryStream(1);
    int c;
    while((c=fin.read())!=-1){
    file.write(c);
    fin.close();
    s.close();
    rs.close();
    catch(IOException e){
    e.printStackTrace();
    System.out.println("Err:"+e);
    I am getting the error as
    java.sql.SQLException: General error
    at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
    at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
    at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(Unknown Source)
    at sun.jdbc.odbc.JdbcOdbcStatement.execute(Unknown Source)
    at sun.jdbc.odbc.JdbcOdbcStatement.executeQuery(Unknown Source)Error! java.sql.SQLException: General error
    at attach.Clobread.main(Clobread.java:30)

    That usually means something is wrong with the syntax of your sql.
    As a guess 'text' is probably a keyword and shouldn't be used as a field name. It is possible that the same is true for 'id'

  • Java.sql.SQLException: No corresponding LOB data found  in XML Publisher

    Hi
    I am getting java.sql.SQLException: No corresponding LOB data found : error when i submit XML Report Publisher request through SRS. I can view the output within the template by pressing the preview button during template creation .When i am submiting the request using SRS and also changing the Option to Excel in the layout format in SRS window and if i see the preview then i found this error ,
    "java.sql.SQLException: No corresponding LOB data found : SELECT FILE_DATA, DBMS_LOB.GETLENGTH(FILE_DATA), FILE_NAME, LAST_UPDATE_DATE FROM XDO_LOBS WHERE LOB_TYPE = :1 AND APPLICATION_SHORT_NAME = :2 AND LOB_CODE = :3 AND LANGUAGE = :4 AND TERRITORY = :5 at oracle.apps.xdo.oa.schema.server.XdoLobsInputStream.<init>(XdoLobsInputStream.java:108) at oracle.apps.xdo.oa.schema.server.LobHelper.getLob(LobHelper.java:877) at oracle.apps.xdo.oa.schema.server.LobHelper.getBlobDomain(LobHelper.java:911)"
    but for PDF it is working correct But it is not working when i submit XML Report Publisher.
    Could some one help me ?
    Our XML Publisher version in 5.6.2 for R12
    Template type is RTF and Template Output Type excelF aswell.
    Thanks
    Suresh

    java.sql.SQLException: No corresponding LOB data found Please see these docs.
    Why Does the 'Concurrent Program Details Report - XML Publisher' Fail with 'No corresponding LOB data found'? [ID 367456.1]
    Attempt To Publish FSG Report In One Step After XML Publisher 5.6 Upgrade Fails With No corresponding LOB data found [ID 398905.1]
    XML Report Preview : Java.Sql.Sqlexception: No Corresponding Lob Data Found [ID 418374.1]
    XML Publisher Report Issues [ID 862644.1]
    Thanks,
    Hussein

Maybe you are looking for