SQL Dates and JAVA

Hi All,
Firstly I am a complete newbie with java code so apologies in advance!! To cut a long story short I have inherited a java app which is of great importance to the company I am working for - in fact its of such importance that the creator saw no reason to document any of its usage - apparently it ran for several years before falling over by which time its author had long gone! - at that point it had to be ported over to new hardware.
Basically the app consists of javascript running from within Tomcat - the data is then dumped into a mysql database.
I have managed to get it working again...except for the date -
the user enters the date in the form eg 04/07/2007 and this is then (or should be ) entered into the database in the format yyyy-MM-dd
Now , when I start mysql up with logging I can see that the insert statement is completing except for the date (which is left as 0000-00-00). It is attempting to enter the date in the following format.
#2006-07-04#
it seems to be the '#' thats screwing it up. If i enter the insert statement manually without the '#' everything is fine. So question is why is this happening and how do I change it.
The last pice of code before the insert is attempted is
stmta.executeUpdate(qry.toString())
I suppose that the toString gives a string representation of the date - I have got myself a java CBT which I am working through :) but I hoped one of you guys would be able to point me in the right direction in the meantime
Many Thanks

yes - I have been through it I think the relevant code is this
rdate = request.getParameter("rdate")
String ndateissued = request.getParameter("ndateissued");
if (ndateissued == null) {
ndateissued = "";
myformat = new SimpleDateFormat("dd/MM/yyyy");
Date issueddate = null
String rdate1 = rdate.substring(8,10) + "/" + rdate.substring(5,7) + "/" + rdate.substring(0,4);
//String rdate1 = rdate.substring(5,7) + "/" + rdate.substring(8,10) + "/" + rdate.substring(0,4);
Date rdate2 = myformat.parse(rdate1);
try {
if (ndateissued.length() > 0) {
issueddate = myformat.parse(ndateissued);
if (issueddate.getTime() < rdate2.getTime()) {
%> <CENTER><FORM><TABLE>
<tr><td>Date issued < Date Recei
ved?????</td></tr>
</TABLE></FORM></CENTER>
<%
return;
return;
if (((issueddate.getTime() - rdate2.getTime()) / 3600000) > 2400 ) {
%> <CENTER><FORM><TABLE>
<tr><td>Date issued > Date Received + 100 days ?????</td></tr>
</TABLE></FORM></CENTER>
<%
return;
dstring = myformat.format(issueddate);
if (!dstring.equals(ndateissued)) {
%> <CENTER><FORM><TABLE>
<tr><td>Date issued - out of range</td></tr>
</TABLE></FORM></CENTER>
<%
return;
ndateissued = ndateissued.substring(6,10) + "-" + ndateissued.substring(3,5) + "-" + ndateissued.substring(0,2);
} catch (Exception e) {
%> <CENTER><FORM><TABLE>
<tr><td>Date issued- parsing error</td></tr>
</TABLE></FORM></CENTER>
<%
return;
Calendar cal = Calendar.getInstance();
cal.setTime(rdate2);
String xdow = cal.get(Calendar.DAY_OF_WEEK) + "";
directtly after this is the code referencing the insert statement.
Many Thanks

Similar Messages

  • Java.sql.Date and java.util.Date - class loaded first in the classpath

    I had two jar files which has java.util.Date and java.sql.Date class file. i want to know whether which class is loaded first in the classpath...
    I like to change the order of loading the class at runtime...
    Is there is any way to change the order of loading of class...
    I may have different version of jar files for example xerces,xercesImpl. some of the code uses xerces ,some of the code uses xercesImpl..i had common classes.
    I like to load the class with the same name according to the order i need..
    Can we do all these in Run time ?????

    I had two jar files which has java.util.Date and
    java.sql.Date class file. i want to know whether
    which class is loaded first in the classpath...
    I like to change the order of loading the class at
    runtime...
    Is there is any way to change the order of loading of
    class...
    I may have different version of jar files for example
    xerces,xercesImpl. some of the code uses xerces ,some
    of the code uses xercesImpl..i had common classes.
    I like to load the class with the same name according
    to the order i need..
    Can we do all these in Run time ?????That is meaningless.
    The classes you are referring to are part of the Java API. Third party jars have no impact on that. And you can't change to the order because java.sql.Data is derived from java.util.Date. So the second must load before the first.
    And if you have two jar files with those classes in them (and not classes that use them) then you either should already know how to use them or you should stop trying to do whatever you are doing because it isn't going to work.

  • Java.util.Date and java.sql.Date

    when i am trying to displaying date in my jsp page errors occurs saying that java.util.date and java.sql.date are matching..
    i have some sql statements which i need to execute in the page.so i cant delete that import sql statement.
    so what is the solution for this.
    i want to display the date as 19th april 2003....in the jsp page.
    thank u

    You should use full names.
    java.util.Date date;
    java.sql.Date sdate;
    ..And it may be a good idea to delete one of the two "import" declaration of packages.

  • Import and process larger data with SQL*Loader and Java resource

    Hello,
    I have a project to import data from a text file in a schedule. A lager data, with nearly 20,000 record/1 hours.
    After that, we have to analysis the data, and export the results into a another database.
    I research about SQL*Loader and Java resource to do these task. But I have no experiment about that.
    I'm afraid of the huge data, Oracle could be slowdown or the session in Java Resource application could be timeout.
    Please tell me some advice about the solution.
    Thank you very much.

    With '?' mark i mean " How i can link this COL1 with column in csv file ? "
    Attilio

  • 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.

  • Convert java.sql.Date to java.util.Date

    How do i convert a java.sql.Date to java.util.Date ?
    SimpleDateFormat formatter = new SimpleDateFormat ("dd/MM/yy HH:mm");
    Date received=myresultset.getDate(1);
    String utildate = formatter.format(received);
    <%=utildate%>
    Result : doesn't keep the HH:mm format
    14/03/04 00:00
    Ideas ?

    There is simple way to do this job...
    java.util.Date utilDate = new java.util.Date();
    java.sql.Data sqlDate = new java.sql.Date(utilDate.getTime())
    Enjoy Coding ! ! ! ! !

  • 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

  • PL/SQL Procedure and Java

    Hi All,
    I am working on a Data Warehousing Product and generating Web Reports.
    These Web Reports are JSPs.
    The basic architechture used for this is :
    1. Get the inputs required for Report Generation through a Web GUI
    2. Validate and Process (If Valid) the inputs so that it can be applied on the Data in the DB to fetch appropriate information.
    3. The Data from the DB is retreived in the form of PL/SQL Procedures, which take the Processed information from Step 2 as Input and give the Output in the form of REF CURSORS.
    Note: There are a many PL/SQL Procedures that are being executed, based on the configuration the Client has set. This configuration enables the Client to set the columns he wants to see in the Web Reports. This configuration is set before the Reports are run.
    4. A call is made from Java to Oracle, each time a PL/SQL Procedure need to be executed. The REF CURSOR received as an Output from the PL/SQL Procedure is processed.
    5. The next PL/SQL Procedure is called (if existing), else the Processed Data (from REF CURSOR Output) is displayed in the JSP as Web Reports.
    The issue with above architechture is the PERFORMANCE.
    I would like to know:
    - The various ways in which data can be EFFICIENTLY & QUICKLY retrieved from PL/SQL Procedure in Java.
    - Are there any APIs that improve the Java-Oracle Data Fetch Efficiency
    - Is there any Java Framework available that can be used to increase the spped of Web Report generation.
    - Do you suggest any changes in the above mentioned architechture, that make this work a Sweet Sixeen Year olg guy! ;)
    - In general, any input that can increase the Speed of Web Report Generation.
    Kindly let me know if I have not been clear at any point, so that I can re-explain the same more clearly.
    And the most important thing, kindly scrap down your thoughts about the same.
    Thanks a lot in advance for your VALUABLE INPUTS.
    - Vikas

    Spring
    http://www.springframework.org/
    http://static.springframework.org/spring/docs/2.0.x/reference/jdbc.html
    http://static.springframework.org/spring/docs/2.0.x/reference/jdbc.html#jdbc-StoredProcedure

  • Sql date and util date problem: plz help

    Hi,
    Following is the scenario I am dealing with....
    I have two feilds in the DB, of type Datetime. First field say.. 'DBDate' have date in it, and second field 'DBTime' has time in it. This much part I can not change.... I can change rest of the part so please guide me accordingly....
    I am getting both the values from the DB using
    long day = rs.getDate("DBDate").getTime();
    long tme = rs.getTime("DBTime").getTime();Now I have to create a completly new java.util.Date object using this date and time. So, I am adding both the long values and trying to create a new data object usingjava.util.Date ext = new java.util.Date(day+tme); But the ext date over here is 6 hrs later time than actual text of the Date in the DB. that is if the date and time in the DB is "5/27/2003" and "4:40:00 PM" the resulting date is "5/27/2003 10:40:00 PM", which could be equivalent GMT time w.r.t. the DB Timezone.
    But I want the final date to be the same as the DB Time Zone.....
    if you need more detailed information reply me... i will post it .....
    Thank a lot in advance...
    Ri

    But the ext date over here is 6 hrs later time than
    actual text of the Date in the DB. that is if the date
    and time in the DB is "5/27/2003" and "4:40:00 PM" the
    resulting date is "5/27/2003 10:40:00 PM", which could
    be equivalent GMT time w.r.t. the DB Timezone.
    How do you know that that is the date in java?
    Are you doing this?
    System.out.println("d=" + mydate);
    If so, and as previously pointed out, you are printing out a time that is relative to your time zone. Is the time in the database relative to your time zone? If not then you have a problem. And if the time in the database is relative to any time zone other than GMT then your extraction method is incorrect as well.

  • SQL Loader and Java

    Hi,
    I am using a Java Stored Procedure to invoke a SQL Loader process. The RDBMS Version is 8.1.7 on HP-UX 11. I invoke the procedure by calling: exec runcommand('sqlldr user=scott/tiger@orcl control=/home/mydir/ctlfile.ctl log=/home/mydir/logfile.log direct=true errors=550')
    where runcommand is the name of the java stored procedure.
    The SQL Loader process returns a value of 3 which is the return value for an Operating System Error. I am unable to find any errors related to the Operating System. Is there any particular environment variable which needs to be set before running the process.
    I was able to run the same Java Stored Procedure on Personal Oracle on Windows XP without any problems.
    TIA,
    Ramesh

    Hi,
    Make sure that the path for data file in control file is correct.
    Then it serves your purpose.
    Otherwise, give full path to "sqlldr", then run it.
    Please let me know the result.
    Thanks
    Srinivasa Rao

  • SQL Injection and Java Regular Expression: How to match words?

    Dear friends,
    I am handling sql injection attack to our application with java regular expression. I used it to match that if there are malicious characters or key words injected into the parameter value.
    The denied characters and key words can be " ' ", " ; ", "insert", "delete" and so on. The expression I write is String pattern_str="('|;|insert|delete)+".
    I know it is not correct. It could not be used to only match the whole word insert or delete. Each character in the two words can be matched and it is not what I want. Do you have any idea to only match the whole word?
    Thanks,
    Ricky
    Edited by: Ricky Ru on 28/04/2011 02:29

    Avoid dynamic sql, avoid string concatenation and use bind variables and the risk is negligible.

  • A silly question about oracle.sql.timestamp and java.sql.timestamp

    Hi,
    I'm looking at a method that takes objects of type Object and does stuff if the object is really a java.sql.timestamp. If it is not then an error is flagged. In my case it flags an error when an object of type oracle.sql.timestamp is passed to it. Not really entirely comfortable with java (i'm still learning it), here's my stupid question :- why isn't oracle.sql.timestamp a subclass of java.sql.timestamp? Also in various books it indicates that java.sql.timestamp maps to oracle.sql.timestamp. Does that mean you have to physically do the mapping:
    i.e.
    java.sql.Timestamp t = new Timestamp( new oracle.sql.Timestamp( CURRENTTIMESTAMP ).timestampValue() );
    or is there something else to it.
    Thanks.
    Harold.

    The best forum for this is probably Forum Home » Java » SQLJ/JDBC
    Presumably you are refering to oracle.sql.TIMESTAMP. While this is intended to (and does) correspond to java.sql.Timestamp it can't be a subclass because it needs to be a subclass of oracle.sql.Datum.

  • SQL Developer and Java GUI problems

    I am having a problem with all the java apps i use, including Oracle SQL Developer. When i load up SQL developer, the top of the "Connections" text is chopped off as well as all the table names in the list when I make a connection. Also the java buttons are rather large. Almost as if they have a carriage return in the text of the button.
    Its seems the gui configuration for java has been corrupted, but i cannot find where to modify those settings. I cant find anything on the internet on this. I have checked my video card settings and modified them to see if that is the issue, but it doesnt fix the problem.
    Since other java apps do the same thing, I know its a java issue, but Ive uninstalled all the JRE's and JDKs i have and reinstalled them, and I still have the problem.
    Im on an Windows XP box and running the JDK and JRE 1.5.0_09 versions. Any help would be appreciated. its very annoying to not be able to read some of the text in the java apps including sql developer due to the tops being cut off.
    I have an ATI RADEON 7000 on an DELL optiplex gx620.
    any help would be appreciated

    The first thing to try, if you haven't already, is to update your video driver.

  • SQL (JDBC and JAVA)

    Hi
    I have have problem in generating a results from my SQL command. Apparently the query run successfully but it fails to oick up the data in the table for display. Please find the code below:-
    public class QueryTableModel extends AbstractTableModel {
    ScrollingPanelVesDue screenVesDuePanel;
    JTextArea output;
    String url;
    Connection connection;
    Vector totalrows;
    String[] colheads =
    { " Vessel Ref "," Agent ", " Name of Vessel ", "Arrival Date",
    " Rem on Est Date of Arrival" };
    public QueryTableModel( Connection dbc, ScrollingPanelVesDue s,
    JTextArea o ) {
    connection = dbc;
    screenVesDuePanel = s;
    output = o;
    totalrows = new Vector();
    //int i
    public String getColumnName ( ) {
    return colheads [ 5 ]; //i
    //set the column number
    public int getColumnCount() {
    return 5;
    //set the row number
    public int getRowCount() {
    return totalrows.size();
    public Object getValueAt ( int row, int col ) {
    return ( ( String[] ) totalrows.elementAt( row ) ) [ col ];
    //sets the table cells non editable
    public boolean isCellEditable ( int row, int col ) {
    return false;
    public void fire () {
    fireTableChanged (null);
    //executes query
    public void query() {
    try {
    Statement statement = connection.createStatement( ResultSet.TYPE_SCROLL_SENSITIVE,
    ResultSet.CONCUR_READ_ONLY);
    String query = "SELECT Vessel_Ref, Type, Agent, EDA, EstRemarks FROM VesselGeneral " +
    "WHERE EDA=" + screenVesDuePanel.F_Date.getText() +
    "AND " + screenVesDuePanel.P_Date.getText();
    output.append( "\nsending query:\n" +
    connection.nativeSQL( query ) + "\n" );
    ResultSet rs = statement.executeQuery( query );
    totalrows = new Vector();
    while ( rs.next () ) {
    String[] record = new String[ 5 ];
    for ( int i = 0; i < 5; i++ ) {
    record[ i ] = rs.getString( i + 2 );
    totalrows.addElement( record );
    output.append( "\nQuery successful\n" );
    statement.close();
    catch ( SQLException sqlex ) {
    output.append( sqlex.toString() );
    I need urgent help
    harry

    hi dave
    Please find all of code as stated as i am seriously finding it tough to solve the problem. Please note that in all i have 21 fields in the table and out of these i am selecting fields 2, 3,4 ,5 and 21 in the criteria of earliest and present dates entered by the user.
    CODE
    public class QueryVesDue extends JFrame implements ActionListener {
    private ScrollingPanelVesDue screenVesDuePanel;
    private ScrollingPanelVesGen screenVesGenPanel;
    private JTextArea output;
    private String url;
    private Connection connection;
    private JScrollPane jspane;
    private Container c;
    private QueryTableModel qtbl;
    private JTable jtbl;
    private boolean firsttime = true;
    public QueryVesDue( Connection dbc, ScrollingPanelVesDue s, JTextArea o ) {
    super ( "VESSELS DUE IN PORT" );
    connection = dbc;
    screenVesDuePanel = s;
    output = o;
    public void actionPerformed ( ActionEvent e ) {
    if ( ! screenVesDuePanel.F_Date.getText().equals( "" ) &&
    ! screenVesDuePanel.P_Date.getText().equals( "" ) ) {
    // set up the table GUI
    if ( firsttime ) {
    c = getContentPane();
    c.setLayout( new FlowLayout () );
    qtbl = new QueryTableModel ( connection, screenVesDuePanel, output );
    qtbl.query();
    jtbl = new JTable ( qtbl );
    TableColumn tcol = jtbl.getColumnModel().getColumn( 0 );
    tcol.setPreferredWidth( 50 );
    jspane = new JScrollPane ( jtbl );
    c.add( jspane );
    setSize(600, 500);
    firsttime = false;
    else {
    qtbl.query();
    qtbl.fire();
    TableColumn tcol = jtbl.getColumnModel().getColumn( 0 );
    tcol.setPreferredWidth ( 150 );
    show();
    else
    output.append( "\n Find data before generating query \n");
    public class ScrollingPanelVesDue extends JPanel {
    JTextField F_Date, P_Date; // package access
    JLabel lF_Date, lP_Date;
    public ScrollingPanelVesDue() {
    // Label panel
    JPanel labelPanel = new JPanel();
    labelPanel.setLayout(
    new GridLayout( 2, 1, 2, 2 ) ); //labels
    lF_Date= new JLabel ( " Enter Earliest Date: " );
    labelPanel.add( lF_Date);
    lP_Date = new JLabel ( " Enter Due Date: " );
    labelPanel.add( lP_Date );
    // TextField panel
    JPanel screenVesDuePanel = new JPanel();
    screenVesDuePanel.setLayout(
    new GridLayout( 2, 1 ) );
    F_Date = new JTextField( 11 );
    F_Date.setText( "dd/mm/yyyy" );
    screenVesDuePanel.add( F_Date ).setBackground( Color.orange );
    P_Date = new JTextField( 11 );
    P_Date.setText( "dd/mm/yyyy" );
    screenVesDuePanel.add( P_Date ).setBackground( Color.orange );
    //screenVesDuePanel.add( )
    //Accessibility section - relate labels and text fields
    // for use by assistive technologies
    lF_Date.setLabelFor( F_Date );
    lP_Date.setLabelFor( P_Date );
    setLayout( new GridLayout( 1, 2 ) );
    add( labelPanel );
    add( screenVesDuePanel );
    public class QueryVesDue extends JFrame implements ActionListener {
    private ScrollingPanelVesDue screenVesDuePanel;
    private ScrollingPanelVesGen screenVesGenPanel;
    private JTextArea output;
    private String url;
    private Connection connection;
    private JScrollPane jspane;
    private Container c;
    private QueryTableModel qtbl;
    private JTable jtbl;
    private boolean firsttime = true;
    public QueryVesDue( Connection dbc, ScrollingPanelVesDue s, JTextArea o ) {
    super ( "VESSELS DUE IN PORT" );
    connection = dbc;
    screenVesDuePanel = s;
    output = o;
    public void actionPerformed ( ActionEvent e ) {
    if ( ! screenVesDuePanel.F_Date.getText().equals( "" ) &&
    ! screenVesDuePanel.P_Date.getText().equals( "" ) ) {
    // set up the table GUI
    if ( firsttime ) {
    c = getContentPane();
    c.setLayout( new FlowLayout () );
    qtbl = new QueryTableModel ( connection, screenVesDuePanel, output );
    qtbl.query();
    jtbl = new JTable ( qtbl );
    TableColumn tcol = jtbl.getColumnModel().getColumn( 0 );
    tcol.setPreferredWidth( 50 );
    jspane = new JScrollPane ( jtbl );
    c.add( jspane );
    setSize(600, 500);
    firsttime = false;
    else {
    qtbl.query();
    qtbl.fire();
    TableColumn tcol = jtbl.getColumnModel().getColumn( 0 );
    tcol.setPreferredWidth ( 150 );
    show();
    else
    output.append( "\n Find data before generating query \n");
    public class QueryTableModel extends AbstractTableModel {
    ScrollingPanelVesDue screenVesDuePanel;
    JTextArea output;
    String url;
    Connection connection;
    Vector totalrows;
    String[] colheads =
    { " Vessel Ref "," Agent ", " Name of Vessel ", "Arrival Date",
    " Rem on Est Date of Arrival" };
    public QueryTableModel( Connection dbc, ScrollingPanelVesDue s,
    JTextArea o ) {
    connection = dbc;
    screenVesDuePanel = s;
    output = o;
    totalrows = new Vector();
    public String getColumnName ( int i ) {
    return colheads [ i ];
    //set the column number
    public int getColumnCount() {
    return 5;
    //set the row number
    public int getRowCount() {
    return totalrows.size();
    public Object getValueAt ( int row, int col ) {
    return ( ( String[] ) totalrows.elementAt( row ) ) [ col ];
    //sets the table cells non editable
    public boolean isCellEditable ( int row, int col ) {
    return false;
    public void fire () {
    fireTableChanged (null);
    //executes query
    public void query() {
    try {
    Statement statement = connection.createStatement( ResultSet.TYPE_SCROLL_SENSITIVE,
    ResultSet.CONCUR_READ_ONLY);
    String query = "SELECT Vessel_Ref, Type, Agent, EDA, EstRemarks FROM VesselGeneral " +
    "WHERE EDA BETWEEN " + screenVesDuePanel.F_Date.getText() +
    "AND AND EDA " + screenVesDuePanel.P_Date.getText() + "";
    output.append( "\nsending query:\n" +
    connection.nativeSQL( query ) + "\n" );
    ResultSet rs = statement.executeQuery( query );
    totalrows = new Vector();
    while ( rs.next () ) {
    String[] record = new String[ 20 ];
    for ( int i = 0; i < 20; i++ ) {
    record[i] = rs.getString( i + 2 );
    totalrows.addElement( record );
    output.append( "\nQuery successful\n" );
    statement.close();
    catch ( SQLException sqlex ) {
    output.append( sqlex.toString() );
    PLEASE HELP
    HARRY

Maybe you are looking for

  • Sales data not replicated for materials from ECC

    Hello Experts, When creating a meterial in ECC, the same gets replicated to CRM 7, but the data maintained in the sales tabs of ECC is not getting replicated to the CRM material master Sales & Distribution tab. I have already maintained the correspon

  • Internet: leopard: yes - snow leopard: no (tried all your tips)

    i have upgraded my new macbook pro 17 to snow leopard and i dont get connections to the internet via safari, mail and firefox anymore. (skype still works!!??) wlan: full reception but no connection ethernet: on, but not working either i have rebooted

  • Ipod Touch Stopped Working For No Reason!!

    Hi, First time post. Basically, until about a week ago my ipod was working perfectly. It ran out of battery so charged up over night as usual. When i tried to turn it on the next day nothing happened at all. I tried to plug it into charge in the wall

  • QUERY EXECUTION START TIME

    a session is executing a query.I want to know at what time the query has started execution.Its a long running query and not yet finished execution? Thankx..

  • Installing NWDI on CE

    HI, We are trying to setup NWDI for CE 7.1. When we go through the documents, we understand that we need to setup NWDI in a separate NW 7.0 server and use in CE environment. Cant we install NWDI on CE itself instead of installing in NW7.0 server. Oth