Streaming data in java

My applet needs to stream data from a server.
Server is .NET/C#
I have two implementations but both are not the exact thing which i want.
So if anyone have any better ideas please do give suggestions.
1) My server application will write to a hidden variable.
My client java program representing the applet have a thread which checks the value of this variable and once the variable gets data use that to do the task.
The task in my scenario is printing.
2) My server will send some text in a specified format using the Response.Write() function
My java program reads it using
DataInputStream in = new DataInputStream(urlconnection.getInputStream());Now the problem with the second implementation is response.write() displays the content on the page also which makes it visible to all.Also in addition to the text written using Reponse.Write() the input stream returns all the html tags also.
So can anyone tell me a better way to stream data in java.
I know both these implementations are not implementing the concept of streaming.
Thank You.

here is my applet code.
checkJavaScriptEvent obj=new checkJavaScriptEvent();
               obj.start();
               URL currentPage=getCodeBase();
               String protocol = currentPage.getProtocol();
               String host=currentPage.getHost();
               int port=currentPage.getPort();
               String urlSuffix="/PrintAppletCSharp/Default.aspx";
               System.out.println("currentPage : " + currentPage + "\nprotocol : " + protocol + "\nhost : " + host + "\nport : " + port);
               try {
                    URL dataUrl=new URL(protocol,host,port,urlSuffix);
                    URLConnection connection=dataUrl.openConnection();
                    connection.setUseCaches(false);
                    //connection.setRequestProperty("header", "value");
                    System.out.println("Got a connection");
                    //BufferedReader in=new BufferedReader(new InputStreamReader(connection.getInputStream()));
                     DataInputStream in = new DataInputStream(connection.getInputStream());
                    //byte[] b=new byte[20];
                    //int count =is.read(b);
                    System.out.println("After Getting a connection");// + count + " : " + b.toString());
                    String line="";
                    while(!line.equals("EndScriptPrint"))
                         line=in.readLine();
                         if(!line.equals("StartScriptPrint") && !line.equals("EndScriptPrint"))
                              fromServer+=line + "\n";
                         System.out.println("Line " + line);
                    FileWriter fw=new FileWriter("t.txt");
                    fw.write(fromServer);
                    fw.close();
                    Process p=Runtime.getRuntime().exec("notepad.exe t.txt");
                    repaint();
               } catch (Exception ex) {
                    ex.printStackTrace();
               }

Similar Messages

  • Streaming data to LONG columns in Oracle 7.3.2.3.0

    I am trying to stream data to a LONG column. I'm using Oracle
    Server 7.3.2.3.0 on AIX and JDBC driver 8.0.4 on Windows NT 4
    SP5.
    I include sample tables/programs at the end, but here's the
    summary of what's happening:
    I'm creating a byte array of length 2500. If I use
    setAsciiStream I get the following exception when I execute the
    prepared statement:
    java.sql.SQLException: Data size bigger than max size for this
    type
    at oracle.jdbc.dbaccess.DBError.check_error(DBError.java)
    at oracle.jdbc.ttc7.TTCItem.setArrayData(TTCItem.java)
    at oracle.jdbc.driver.OraclePreparedStatement.setItem
    (OraclePreparedStat
    ement.java)
    at
    oracle.jdbc.driver.OraclePreparedStatement.setAsciiStream
    (OraclePrepa
    redStatement.java)
    at TestOracle.main(TestOracle.java:26)
    If I use setBinaryStream I get this exception:
    java.sql.SQLException: ORA-01461: can bind a LONG value only for
    insert into a LONG column
    at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java)
    at oracle.jdbc.ttc7.Oall7.receive(Oall7.java)
    at oracle.jdbc.ttc7.TTC7Protocol.doOall7
    (TTC7Protocol.java)
    at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch
    (TTC7Protocol.java)
    at oracle.jdbc.driver.OracleStatement.doExecuteOther
    (OracleStatement.jav
    a)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithBatch
    (OracleStatement
    .java)
    at oracle.jdbc.driver.OracleStatement.doExecute
    (OracleStatement.java)
    at
    oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout
    (OracleStateme
    nt.java)
    at
    oracle.jdbc.driver.OraclePreparedStatement.executeUpdate
    (OraclePrepar
    edStatement.java)
    at oracle.jdbc.driver.OraclePreparedStatement.execute
    (OraclePreparedStat
    ement.java)
    at TestOracle.main(TestOracle.java:27)
    My Oracle7 manual states that LONG columns can store 2GB of text.
    I tried the above with LONG RAW columns and it worked fine.
    Can anyone explain why I get this error? I've tried it with
    different sizes and when the data is <2000 bytes it works fine
    for LONG columns.
    My table is simple:
    create table TestLongs (key INTEGER PRIMARY KEY, data LONG);
    My Java code is also very simple:
    public class TestOracle
    public static void main(String[] args)
    Connection con = null;
    PreparedStatement pstmt = null;
    try
    Class.forName("oracle.jdbc.driver.OracleDriver");
    con = DriverManager.getConnection(
    "jdbc:oracle:thin:@itchy:1526:test",
    "System", "<OMITTED>");
    byte[] data = new byte[2500];
    for (int i=0; i< 2500; i++)
    data[i] = 53;
    String sql = "INSERT INTO TestLongs (key, data)
    VALUES(1, ?)";
    pstmt = con.prepareStatement(sql);
    ByteArrayInputStream bis = new ByteArrayInputStream
    (data);
    pstmt.setAsciiStream(1, bis, data.length);
    pstmt.execute();
    catch (SQLException e)
    System.err.println("An error occurred with the
    database: " + e);
    e.printStackTrace();
    catch (Exception e)
    System.err.println("Oracle JDBC driver not found." +
    e);
    e.printStackTrace();
    finally
    try
    if (pstmt != null)
    pstmt.close();
    if (con != null)
    con.close();
    catch (SQLException e)
    System.err.println("Unable to close
    statement/connection.");
    null

    Robert Greig (guest) wrote:
    : I am trying to stream data to a LONG column. I'm using Oracle
    : Server 7.3.2.3.0 on AIX and JDBC driver 8.0.4 on Windows NT 4
    : SP5.
    I tried it with the old 7.3.x JDBC driver and it works fine. I
    also noticed after further testing that it sometimes worked
    with the 8.0.4 driver. Looks like a bug in the 8.0.4 driver or
    some wacky incompatibility.
    null

  • Access Price data form Java App

    Hi All,
    This is a question of can it be done.
    If a Java program runs from a website and is used to stream currency price data can I use another program to access the price data that is being streamed to the Java program?
    I do not have access to any API's just the GUI.
    Program is at http://fxtrade.oanda.com/fxgame/ but requires a login. Is free
    Thanks

    If a Java program runs from a website and is used to
    stream currency price dataI guess we are talking about an applet?
    can I use another program
    to access the price data that is being streamed to
    the Java program?No
    Kaj

  • Creating Table Data in Java

    Hi All,
    there are some examples "Creating Table Data in Java" in the Oracle ADF UIX Developer's Guide Chapter 9 - Creating Tables in ADF UIX.
    Especially the directory listing is interesting. It works fine in my testproject.
    But how can I pass parameters to this class dynamically. (e.g. path of the directory). If I add a new parameter to the method
    public static DataObject getDirectoryData(RenderingContext context,String namespace, String name, String myPara)
    I get the following error message:
    Warning(124,58): test.uix: Parsing error, line 124, column 58: Could not find method getDirectoryData in test.MyTable:Method getDirectoryData does not have the correct signature.
    Thanks for any tips or idea
    Roger

    Thank you for answering.
    May I use this example in a data provider with a dynamic variable for the path?
    If I use my own class inside an INVOKE element the problem is as follows: I'm not able to format the return stream. It contains a StringArray.
    In a servlet I can use the following simple syntax for a HTML choicebox:
    -------------------snipp-----------------------------------
    buffer = buffer + "<select name=\"p_file\" size=\"1\">";
    for (int i=0 ;i<p_length ; i++ ) {
    buffer = buffer + "<option value=\"" +lines[i]+"\">" + lines;
    buffer = buffer + "</select>";
    -------------------snapp-----------------------------------
    I don't find a solution to use a for-loop in uix. The JSTL syntax doesn't work there.
    Any ideas?
    THX Roger

  • Transferin Huge data via Java sockets! Problematic!

    Hello!
    I tried to write a server app in Java to get huge data which contains a meta data XML format about file information and then binary data of file...
    I get data from socket with DataInputStream and then I read like this:
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    while((got = in.read(res)) != -1)
    out.write(res, 0, got);
    byte[] recieved = out.toByteArray();
    I saw that if I store all receiving data in array it takes alot of memory and I cannot even transfer files which have 650MB of data.
    So I decided to write what I get from socket directly to a file...
    I used FileOutputStream to do it...
    But problem is -> THIS SERVER IS SO SLOW!
    I wrote similar code in VB6... And it receives data from client SO SO SO faster than Java...
    What's wrong with my code which makes works slow?
    how can I solve it?
    You experts have any server code example for receiving huge amount of data?
    Please advice...
    Thanks alot

    How to use buffered streams: go to Java tutorials http://java.sun.com/docs/books/tutorial/index.html - look for "basic input/output", and "buffered streams" under it. You'll want BufferedInputStream and BufferedOutputStream.
    Alternatively:
            byte buf = new byte[8192];
            while (true) {
                int count = in.read(buf);
                if (count == -1)
                    break;
                out.write(buf, 0, count);
            }If at all possible, don't read the whole file into memory at once. Read with a loop like the above and do whatever you are supposed to do with the data a chunk at a time. But if you must have it in memory then I guess you got to do what you got to do.

  • Streaming data into LONG results in ORA-24307

    I am migrating an application to a new environment. During testing I am receiving the following error when trying to insert a record into an Oracle 8.1.7.4 table:
    Error saving report: update BlobPiece osetpi(): ORA-24307: invalid length for piece
    The table has a column defined as LONG. I am using a prepared staement and setAsciiStream to perform the insert. I have been able to determine that the error happens when the data being streamed exceeds 4000 bytes (i.e. 4001 bytes).
    Connection to the table is made by using a datasource with the ORACLE_OCI driver. If I change the connection to use an Oracle thin driver, the insert is performed (code provided below).
    I would prefere not to change the connection method if possible. Any help resolving this problem would be appreciated. Thanks.
    Here is the insert code being used:
    public void create(SavedReportImpl report, String userId)
    throws ReportManagerException {
    StringBuffer sql = new StringBuffer();
    // NOTE: Must utilize a prepared statement since this insert contains
    // an Oracle Long column type
    java.sql.PreparedStatement statement = null;
    String modelCd = report.getModel().getModelCd().toUpperCase();
    if (modelCd.length() != 7) {
    modelCd = " " + modelCd;
    sql.append("INSERT ");
    sql.append("INTO ");
    sql.append("PRCT012 ");
    sql.append("(");
    sql.append("MODL_YR_NBR, ");
    sql.append("PRICE_CD, ");
    sql.append("MDSNG_MODL_DESGTR, ");
    sql.append("EFFECTIVE_DT, ");
    sql.append("REPORT_TP, ");
    sql.append("REPORT_SUBTP, ");
    sql.append("RESTRICTION, ");
    sql.append("PRICE_DESC, ");
    sql.append("VEHICLE_LINE, ");
    sql.append("MODL_DESC, ");
    sql.append("CURRENCY_CD, ");
    sql.append("CURRENCY_NM, ");
    sql.append("SOP_INDCTR, ");
    sql.append("LAST_UPDT_USERID, ");
    sql.append("LAST_UPDT_TMSTM, ");
    sql.append("REPORT_HTML_STRING) ");
    sql.append("VALUES (" );
    sql.append("'" + report.getModel().getModelYear() + "', ");
    sql.append("'" + report.getPriceCd().toUpperCase() + "', ");
    sql.append("'" + modelCd + "', ");
    sql.append("'" + dateFormatter.formatDatetoDBDateString(report.getEffectiveDate()) + "', ");
    sql.append(report.getReportType() + ", ");
    sql.append(report.getReportSubtype() + ", ");
    if (report.getModel().getRestriction() == null || report.getModel().getRestriction().length() == 0) {
    sql.append("NULL, ");
    } else {
    sql.append("'" + report.getModel().getRestriction().toUpperCase() + "', ");
    sql.append("'" + report.getPriceCdDescription() + "', ");
    sql.append("'" + report.getModel().getVehicleLine().toUpperCase() + "', ");
    sql.append("'" + report.getModel().getDescription() + "', ");
    sql.append("'" + report.getCurrency().getCurrencyCd().toUpperCase() + "', ");
    sql.append("'" + report.getCurrency().getCurrencyNm() + "', ");
    sql.append(report.isSOP() ? "'Y', " : "'N', ");
    sql.append("'" + userId.toUpperCase() + "', ");
    sql.append("'" + dateFormatter.formatDatetoDBDateTimeString(new java.util.Date()) + "', ");
    sql.append("?) "); // LONG COLUMN TO BIND
    //NOTE: only bind one column when there is an ORACLE LONG
    try {
    statement = connection.prepareStatement(sql.toString());     
    String html = com.eds.csdd.util.StringUtils.replaceAll(report.getHTML(), "'", "''");
    byte[] bytes = html.getBytes();
    java.io.InputStream is = new java.io.ByteArrayInputStream(bytes);
    statement.setAsciiStream(1, is, bytes.length);
    int resultCode = statement.executeUpdate();
    } catch (java.sql.SQLException sqle) {
    throw new ReportManagerException(sqle.getMessage());
    } catch (Exception e) {
    e.printStackTrace();
    throw new ReportManagerException(e.getMessage());                    
    } finally {                                   
    if (statement != null) {
    try { statement.close(); } catch (java.sql.SQLException re) {}
    Here is the connection code using the datasource:
    public java.sql.Connection getConnection(String dataSourceName) throws java.sql.SQLException {
    javax.naming.InitialContext               dsCTX          = null;
    javax.sql.DataSource               ds1          = null;
    java.sql.Connection                    conn          = null;
    String dataSource = rte.getProperty(dataSourceName, "datasource","datasourcenotfound");
    try {
         dsCTX = new javax.naming.InitialContext();
         ds1 = (javax.sql.DataSource)dsCTX.lookup("java:comp/env/" + dataSource);
    } catch (javax.naming.NamingException e){
         throw new java.sql.SQLException("Naming Exception:" + e.getMessage());
    if (ds1 == null)
         throw new java.sql.SQLException("datasource not provided");
    else
         conn = ds1.getConnection();
    return conn;
    Here is the connection code using the thin driver:
    public java.sql.Connection getConnection(String dataSourceName) throws java.sql.SQLException {
    java.sql.DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
    // open a connection to the database
    java.sql.Connection conn = java.sql.DriverManager.getConnection (
                             "jdbc:oracle:thin:@###.##.###.###:1521:SID",
                             "userid",
                             "password");
    return conn;
    }

    Robert Greig (guest) wrote:
    : I am trying to stream data to a LONG column. I'm using Oracle
    : Server 7.3.2.3.0 on AIX and JDBC driver 8.0.4 on Windows NT 4
    : SP5.
    I tried it with the old 7.3.x JDBC driver and it works fine. I
    also noticed after further testing that it sometimes worked
    with the 8.0.4 driver. Looks like a bug in the 8.0.4 driver or
    some wacky incompatibility.
    null

  • Exceptions, odd behavior of streaming data to outputstream

    I have a servlet which writes mp3 data to the dataoutputstream of a servlet response object. For some reason, the servlet method writes the data out and gets an exception. Then the method/servlet is called again automatically and begins to write the data out again. The exception is below. In the end the mp3 is delivered to the client fine, however with server side exceptions and odd behavior.
    try {
              int len = 0;
              resp.setContentType("audio/mpeg");
              String filename = req.getParameter("file");
              File mp3 = new File(mediaDir + filename);
              byte[] buf = new byte[1024];
              FileInputStream fis = new FileInputStream(mp3);
              DataOutputStream o = new DataOutputStream(resp.getOutputStream());
              while( (len = fis.read(buf)) != -1) {            
                 o.write(buf, 0, len);            
              o.flush();
              resp.flushBuffer();
              o.close();
              fis.close();
           catch(Exception e) {
              System.out.println(e.getMessage());
              e.printStackTrace();
    null
    ClientAbortException:  java.net.SocketException: Connection reset by peer: socket write error
         at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:366)
         at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:403)
         at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:323)
         at org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:392)
         at org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:381)
         at org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:76)
         at java.io.DataOutputStream.write(DataOutputStream.java:90)
         at TrafficControl.streamAudio(TrafficControl.java:639)
         at TrafficControl.processRequest(TrafficControl.java:136)
         at TrafficControl.doGet(TrafficControl.java:61)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
         at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
         at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
         at java.lang.Thread.run(Thread.java:595)thanks
    Edited by: black_lotus on 19-Feb-2009 3:08 PM

    There are some versions of some browsers (MS IE) that can call a servlet twice; they only look at the headers at the first request, in order to decide whether to display a "save or open" dialog, or some such reason. Try different browsers; also log the User-Agent header to see if it is "contype", which is present when the multiple request thing happens.
    http://support.microsoft.com/default.aspx?scid=kb;EN-US;q293792
    "Connection reset" can also happen if the client closes the connection without reading the entire response. Occasional resets will happen as users cancel download.
    Not a source of exceptions but something you may still want to consider when sending large responses: by default, the servlet container will have to buffer the entire file in memory to find out its length. To save memory, either set content length before writing the data, or use chunked encoding (google should find details.) That way your write() actually streams data to the user.

  • Report Script returns no data and "java.io.FileNotFoundException" error

    When attempting to write to a new file (Eg: C:\TEST.txt), Report Script returns no data and "java.io.FileNotFoundException" error occurs.
    This error occurs only in Essbase 9.3.1.3 release, however it works fine in release 9.3.1.0.
    After running the report the script, it pops up the follwing message:
    "java.io.FileNotFoundException: ..\temp\eas17109.tmp (The system cannot find the file specified): C:\TEST.txt"
    When checked the TEST.txt, it was empty.

    Sorry folks, I just found out the reason. Its because there was no data in the combination what I was extracting.
    but is this the right error message for that? It should have atleast create a blank file right?

  • Why not Deprecate java.util.Date and java.util.Calendar

    With the introduction of java.time, why did you not flag java.util.Date and java.util.Calendar. These classes have been a bane to every Java developer and should never be used again with the introduction of Java 1.8.

    Adding the @Deprecated annotation would only just provide a warning about an old API and recommendation to the developer(s) to no longer use it. Doing so would not break any existing library out there; in fact quite a number of constructors and methods on the Date class have already been flagged deprecated.
    The new java.time package is far superior to Date/Calendar.

  • Java.sql.Date vs java.util.Date vs. java.util.Calendar

    All I want to do is create a java.sql.Date subclass which has the Date(String) constructor, some checks for values and a few other additional methods and that avoids deprecation warnings/errors.
    I am trying to write a wrapper for the java.sql.Date class that would allow a user to create a Date object using the methods:
    Date date1 = new Date(2003, 10, 7);ORDate date2 = new Date("2003-10-07");I am creating classes that mimic MySQL (and eventually other databases) column types in order to allow for data checking since MySQL does not force checks or throw errors as, say, Oracle can be set up to do. All the types EXCEPT the Date, Datetime, Timestamp and Time types for MySQL map nicely to and from java.sql.* objects through wrappers of one sort or another.
    Unfortunately, java.sql.Date, java.sql.Timestamp, java.sql.Time are not so friendly and very confusing.
    One of my problems is that new java.sql.Date(int,int,int); and new java.util.Date(int,int,int); are both deprecated, so if I use them, I get deprecation warnings (errors) on compile.
    Example:
    public class Date extends java.sql.Date implements RangedColumn {
      public static final String RANGE = "FROM '1000-01-01' to '8099-12-31'";
      public static final String TYPE = "DATE";
       * Minimum date allowed by <strong>MySQL</strong>. NOTE: This is a MySQL
       * limitation. Java allows dates from '0000-01-01' while MySQL only supports
       * dates from '1000-01-01'.
      public static final Date MIN_DATE = new Date(1000 + 1900,1,1);
       * Maximum date allowed by <strong>Java</strong>. NOTE: This is a Java limitation, not a MySQL
       * limitation. MySQL allows dates up to '9999-12-31' while Java only supports
       * dates to '8099-12-31'.
      public static final Date MAX_DATE = new Date(8099 + 1900,12,31);
      protected int _precision = 0;
      private java.sql.Date _date = null;
      public Date(int year, int month, int date) {
        // Deprecated, so I get deprecation warnings from the next line:
        super(year,month,date);
        if(! isWithinRange(this))
          throw new ValueOutOfRangeException((RangedColumn)this, "" + this);
      public Date(String s) {
        super(0l);
        // Start Cut-and-paste from java.sql.Date.valueOf(String s)
        int year;
        int month;
        int day;
        int firstDash;
        int secondDash;
        if (s == null) throw new java.lang.IllegalArgumentException();
        firstDash = s.indexOf('-');
        secondDash = s.indexOf('-', firstDash+1);
        if ((firstDash > 0) & (secondDash > 0) & (secondDash < s.length()-1)) {
          year = Integer.parseInt(s.substring(0, firstDash)) - 1900;
          month = Integer.parseInt(s.substring(firstDash+1, secondDash)) - 1;
          day = Integer.parseInt(s.substring(secondDash+1));
        } else {
          throw new java.lang.IllegalArgumentException();
        // End Cut-and-paste from java.sql.Date.valueOf(String s)
        // Next three lines are deprecated, causing warnings.
        this.setYear(year);
        this.setMonth(month);
        this.setDate(day);
        if(! isWithinRange(this))
          throw new ValueOutOfRangeException((RangedColumn)this, "" + this);
      public static boolean isWithinRange(Date date) {
        if(date.before(MIN_DATE))
          return false;
        if(date.after(MAX_DATE))
          return false;
        return true;
      public String getRange() { return RANGE; }
      public int getPrecision() { return _precision; }
      public String getType() { return TYPE; }
    }This works well, but it's deprecated. I don't see how I can use a java.util.Calendar object in stead without either essentially re-writing java.sql.Date almost entirely or losing the ability to be able to use java.sql.PreparedStatement.get[set]Date(int pos, java.sql.Date date);
    So at this point, I am at a loss.
    The deprecation documentation for constructor new Date(int,int,int)says "instead use the constructor Date(long date)", which I can't do unless I do a bunch of expensive String -> [Calendar/Date] -> Milliseconds conversions, and then I can't use "super()", so I'm back to re-writing the class again.
    I can't use setters like java.sql.Date.setYear(int) or java.util.setMonth(int) because they are deprecated too: "replaced by Calendar.set(Calendar.DAY_OF_MONTH, int date)". Well GREAT, I can't go from a Date object to a Calendar object, so how am I supposed to use the "Calendar.set(...)" method!?!? From where I'm sitting, this whole Date deprecation thing seems like a step backward not forward, especially in the java.sql.* realm.
    To prove my point, the non-deprecated method java.sql.Date.valueOf(String) USES the DEPRECATED constructor java.util.Date(int,int,int).
    So, how do I create a java.sql.Date subclass which has the Date(String) constructor that avoids deprecation warnings/errors?
    That's all I really want.
    HELP!

    I appreciate your help, but what I was hoping to accomplish was to have two constructors for my java.sql.Date subclass, one that took (int,int,int) and one that took ("yyyy-MM-dd"). From what I gather from your answers, you don't think it's possible. I would have to have a static instantiator method like:public static java.sql.Date createDate (int year, int month, int date) { ... } OR public static java.sql.Date createDate (String dateString) { ... }Is that correct?
    If it is, I have to go back to the drawing board since it breaks my constructor paradigm for all of my 20 or so other MySQL column objects and, well, that's not acceptable, so I might just keep my deprecations for now.
    -G

  • How to get the context data using java script in interactive forms

    Hi All,
    How to get the context data using java script in interactive forms by adobe,  am using web dynpro java
    thanks.

    Hi venkat,
    Please Refer this link.
      Populating one Drop-Down list from the selection of another Drop-down list
    Thanks,
    Raju.

  • Writing data from Java to Excel

    Hi,
    I am trying to writhe data from Java to an Excel Sheet by using JACOB.
    This is my code :
    import java.util.*;
    import java.io.*;
    //import cost.util.*;
    import com.jacob.com.*;
    import com.jacob.activeX.*;
    class XLStock
         public static void main(String argv[])
              XLStock xls = new XLStock();
              xls.main2(argv);
         public void main2(String argv[])
              System.setSecurityManager(null);
              System.runFinalizersOnExit(true);
              Vector v = new Vector();
              XLSPutItem pi;
              String sheetfile = null;
              ActiveXComponent xl;
              Object xlo=null;
              Object workbooks;
              Object workbook;
              Object sheets;
              Variant vOptn = new Variant();
              vOptn.noParam();
              try
                   xl = new ActiveXComponent("Excel.Application");
                   xlo = xl.getObject();
                   Dispatch.put(xlo, "Visible", new Variant(true));
                   xl.setProperty("Visible", new Variant(true));
                   workbooks = xl.getProperty("Workbooks").toDispatch();
                   Variant vTemp = new Variant(argv[0]);
                   workbook = Dispatch.invoke(workbooks, "Open", Dispatch.Method,
                        new Variant[] {vTemp, vOptn, vOptn, vOptn, vOptn, vOptn, vOptn, vOptn, vOptn, vOptn, vOptn, vOptn, vOptn},
                        new int[1]).toDispatch();
                   sheets = Dispatch.get(workbook,"Sheets").toDispatch();
                   pi = new XLSPutItem();
                   if (pi.Parse("1:A1;ciao;6"))
                        v.addElement(pi);
                   for (int i=0; i<v.size(); i++)
                        pi = (XLSPutItem)v.elementAt(i);
                        pi.sheet = Dispatch.invoke(sheets, "Item", Dispatch.Get, new Object[] {new Variant(pi.sheetNumber)}, new int[1]).toDispatch();
                        pi.cell = Dispatch.invoke(pi.sheet, "Range", Dispatch.Get, new Object[] {pi.cellName}, new int[1]).toDispatch();
              catch (Exception e)
                   e.printStackTrace();
              pi = (XLSPutItem)v.firstElement();
              Dispatch.put(pi.cell, "Value", "ciao");
    What happen is that my code always fail at this line :
    xl = new ActiveXComponent("Excel.Application");
    whit this error :
    C:\VJWorks\JNI\jxls>java jxls.XLStock
    com.jacob.com.ComFailException: Can't co-create object
    at com.jacob.com.Dispatch.createInstance(Native Method)
    at com.jacob.com.Dispatch.<init>(Dispatch.java)
    at com.jacob.activeX.ActiveXComponent.<init>(ActiveXComponent.java)
    at jxls.XLStock.main2(XLStock.java:53)
    at jxls.XLStock.main(XLStock.java:28)
    Exception in thread "main" java.util.NoSuchElementException
    at java.util.Vector.firstElement(Vector.java:450)
    at jxls.XLStock.main2(XLStock.java:79)
    at jxls.XLStock.main(XLStock.java:28)
    I task that something is wrong in my system configuration.
    I work on a Win2000 platform and Office 97.
    Someone knows the reason of this error and can suggest what to make.
    Thanks in advance.
    Antonio M.

    Antonio, maybe you can post this back to the Jacob list. As an alternative to Jacob, what about Apache POI or writing the data as comma-delimited and opening the file using Runtime?
    Hope that may help.
    Good luck.

  • Mapping of PLSQL  table type  Date to java

    i am having problem in mapping plsql table type DATE in java,
    able to execute procedures which return plsql table type NUMBER,VARCHAR.
    i am using oracle 9 , jdk1.4, oci driver, windows 2000.
    sample code:
    registering:
    st.registerIndexTableOutParameter(15,100,OracleTypes.DATE,1000);
    st.registerIndexTableOutParameter(16,100,OracleTypes.DATE,1000);
    st.execute();
    getting out params in arrays:
    java.sql.Date[] O_lSubFolder_CrOn=(java.sql.Date[])java.sql.Date[] st.getPlsqlIndexTable(15);
    O_lSubFolder_MdOn=(java.sql.Date[])st.getPlsqlIndexTable(16);
    error while executing the code:
    java.sql.SQLException: Invalid PL/SQL Index Table element type
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:180)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:222)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:285)
    at oracle.jdbc.driver.OraclePreparedStatement.checkPlsqlIndexTableBindTypes(OraclePreparedSt
    atement.java:2705)
    at oracle.jdbc.driver.OracleCallableStatement.registerIndexTableOutParameter(OracleCallableS
    tatement.java:834)
    can anyone help me to solve this problem.

    i am having problem in mapping plsql table type
    DATE in java,
    able to execute procedures which return plsql table
    type NUMBER,VARCHAR.
    i am using oracle 9 , jdk1.4, oci driver, windows
    2000.
    sample code:
    registering:
    st.registerIndexTableOutParameter(15,100,OracleTypes.D
    TE,1000);
    st.registerIndexTableOutParameter(16,100,OracleTypes.D
    TE,1000);
    st.execute();
    getting out params in arrays:
    java.sql.Date[]
    O_lSubFolder_CrOn=(java.sql.Date[])java.sql.Date[]
    st.getPlsqlIndexTable(15);
    O_lSubFolder_MdOn=(java.sql.Date[])st.getPlsqlIndexTab
    e(16);
    can anyone help me to solve this problem.1. Write a wrapper procedure that converts the table of dates to either number or date and then re-convert the table back into date.
    2. Since it's an out param you could create a temp table, insert the contents of the index by array into it and return a cursor.
    3. Create a oracle type using CREATE TYPE and then use an array of the type.
    David Rolfe
    Orinda Software

  • How to change a date value from "java.util.Date" to "java.sql.Date"?

    Hi all,
    How to change a date value from "java.util.Date" to "java.sql.Date"?
    I m still confusing what's the difference between them.....
    thanks
    Regards,
    Kin

    Thanks
    but my sql statement can only accept the format (yyyy-MM-dd)
    such as "select * from xx where somedate = '2004-12-31'
    but when i show it to screen, i want to show it as dd-MM-yyyy
    I m using the following to change the jave.util.Date to str and vice versa. But it cannot shows the dd-MM-yyyy. I tried to change the format from yyyy-MM-dd to dd-MM-yyyy, it shows the wrong date in my application.
         public String date2str(java.util.Date thisdate)     {
              if (thisdate != null)     {
                   java.sql.Date thissDate = new java.sql.Date(thisdate.getTime());
                   return date2str(thissDate);
              }     else     {
                   return "";
         public String date2str(java.sql.Date thisdate)     {
              if (thisdate != null)     {
                   SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                   return sdf.format(thisdate);
              }     else     {
                   return "";
         public java.util.Date str2date(String thisdate)     {
              String dateFormat = "yyyy-MM-dd"; // = 1998-12-31
              java.util.Date returndate = null;
              if (thisdate != null)     {
                   SimpleDateFormat dateFormatter = new SimpleDateFormat(dateFormat);
                   try {
                        returndate = dateFormatter.parse(thisdate);
                   } catch (ParseException pe) {
                        System.out.println (pe.getMessage());
              return returndate;
         }

  • Wsimport, mapping of xs:date to java.util.Date via ext file, and -B option

    Summary:
    JDK 1.7.0_09 and wsimport and xjc that comes with it.
    Global JAXB binding to map xs:date to java.util.Date
    I have the following external bindings file:
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
         xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
         elementFormDefault="qualified" attributeFormDefault="unqualified"
         jaxb:extensionBindingPrefixes="xjc" jaxb:version="2.1">
         <xs:annotation>
              <xs:appinfo>
                   <jaxb:globalBindings>
                        <xjc:serializable />
                        <jaxb:javaType name="java.util.Date" xmlType="xs:date" parseMethod="au.com.xxx.jaxb.DateAdapter.parseDate" printMethod="au.com.xxx.jaxb.DateAdapter.printDate" />
                   </jaxb:globalBindings>
              </xs:appinfo>
         </xs:annotation>
    </xs:schema>The au.com.xxx.jaxb.DateAdapter code is as follows:
    package au.com.xxx.jaxb;
    import java.util.Calendar;
    import java.util.Date;
    import java.util.GregorianCalendar;
    import javax.xml.bind.DatatypeConverter;
    public class DateAdapter {
         public static Date parseDate(String s) {
              return DatatypeConverter.parseDate(s).getTime();
         public static String printDate(Date dt) {
              Calendar cal = new GregorianCalendar();
              cal.setTime(dt);
              return DatatypeConverter.printDate(cal);
    }When I run the following wsimport from the command line, I get:
    salvojo@AUD20901BL /cygdrive/c/workspace/JSF/insurance
    $ /cygdrive/c/java/jdk1.7.0_09/x64/bin/wsimport -keep -s gen-src -b external/wsdl/jaxb-bindings.xml -wsdllocation /wsdl/Member.wsdl -d WebContent/WEB-INF/classes external/wsdl/Member.wsdl
    parsing WSDL...
    Generating code...
    Compiling code...
    C:\workspace\JSF\insurance\gen-src\org\w3\_2001\xmlschema\Adapter1.java:13: error: package au.com.xxx.jaxb does not exist
            return (au.com.xxx.jaxb.DateAdapter.parseDate(value));
                                   ^
    C:\workspace\JSF\insurance\gen-src\org\w3\_2001\xmlschema\Adapter1.java:17: error: package au.com.xxx.jaxb does not exist
            return (au.com.xxx.jaxb.DateAdapter.printDate(value));
                                   ^
    2 errors
    compilation failed, errors should have been reportedWhich means that wsimport or xjc needs to know the classpath to find au.com.xxx.jaxb.DateAdapter.
    But how do I pass the classpath from wsimport to the JAXB compiler ?
    There is the -B option in wsimport, but I could not get it to work.
    If I read it correctly, I should be able to pass the -classpath option to the JAXB compiler from wsimport via -B.
    I tried:
    salvojo@AUD20901BL /cygdrive/c/workspace/JSF/insurance
    $ /cygdrive/c/java/jdk1.7.0_09/x64/bin/wsimport -keep -s gen-src -B"-classpath WebContent/WEB-INF/classes" -b external/wsdl/jaxb-bindings.xml -wsdllocation /wsdl/Member.wsdl -d WebContent/WEB-INF/classes external/wsdl/Member.wsdl
    no such JAXB option: -classpath WebContent/WEB-INF/classes
    Usage: wsimport [options] <WSDL_URI>
    where [options] include:
      -b <path>                 specify jaxws/jaxb binding files or additional schemas
                                (Each <path> must have its own -b)
      -B<jaxbOption>            Pass this option to JAXB schema compiler
      -catalog <file>           specify catalog file to resolve external entity references
                                supports TR9401, XCatalog, and OASIS XML Catalog format.
      -d <directory>            specify where to place generated output files
    <...snipped...>... where WebContent/WEB-INF/classes is the classpath where au.com.xxx.jaxb.DateAdapter.class could be found. Obviously it did not like it.
    Also, why is wsimport generate org.w3._2001.xmlschema.Adapter1.java ? All it is doing is wrapping up the exact same call that I have specified in my DateAdapter. How can I tell wsimport or xjc to NOT create that extra Adapter1.java and simply directly use my DateAdapter ??

    create additional column of type LONG to represent date.
    dateFormat is of type java.util.Date:
    long newLongDate = dateFormat.getTime();
    select object(b) from MyEntity b where b.MYLONGDATE > ?1 and b.MYLOGDATE <= ?2

Maybe you are looking for

  • Maximun no of data stored in a internal table

    Hello experts, I need two things, Maximum no of data can be stored to an internal table, as per my knowledge it probably max 2 GB, and the number of records depends on the table line type also. Can anyone give any tentaive maximum no ? again i need t

  • Sender FCC

    Hi, I am doing a file to idoc with sender file with fixed length and get the below error, I have more fields but i have posted only few under row, should I be having one more node above the row? as per Michal's blog, please help /people/michal.krawcz

  • My iTunes is not syncing my computer music library to my iPhone

    See above

  • Cross company banking

    Hi All, I'm not experienced in FI/CO modules so don't be offended if I write mistakes here Is it possible to have kind of "cross company banking" set-up in SAP? I mean that a customer would be invoiced out of different company codes (because he is de

  • I need a border around a subreport

    I want a border around my subreport. But the trick is I want a border that is ALWAYS THERE 100% OF THE TIME NO MATTER IF THE SUBREPORT RENDERS ANYTHING OR NOT. Again, when the subreport is empty and doesn't render, I still want a soplid border around