What is the ploblem with this code?

class lol
Connection con;
ResultSet rs;
String query="";
String scno,bcrcno,prno,prdt,billamt,misamt,miscd,reconchg;
lol()
try{
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String ServerName="127.0.0.1";
String portnum="1521";
String sid="GRC";
String url="jdbc:oracle:thin:@"+ServerName+":"+portnum+":"+sid;
con = DriverManager.getConnection(url,"scott"," tiger");
con.setAutoCommit(true);
Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
query="select ptscno,ptbcrno,ptprno,to_char(ptprdt,'yyyy-mm-dd'),ptblamt,ptmisamt,ptmisamtcd,ptreconchg from payment";
rs=stmt.executeQuery(query);
     while(rs.next())
          java.sql.Date myDate = new java.sql.Date(System.currentTimeMillis());
          rs.updateDate(4, myDate);
          System.out.println(myDate);
          rs.updateRow();
          con.commit();
          con.close();
}catch(Exception e)
System.out.println("connection failed :"+e);
public static void main(String lol[])
new lol();
thanq in advance,
stalin

that was just a simple code,
all other fields are updating except the Date field where i use updateDate method.
please explain or show me some example to update the date filed.
thanq in advance.
stalin.

Similar Messages

  • Please tell me what is the problem with this code

    Hai,
    Iam new to Swings. can any one tell what is the problem with this code. I cant see those controls on the frame. please give me the suggestions.
    I got the frame ,but the controls are not.
    this is the code:
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class ex2 extends JFrame
    JButton b1;
    JLabel l1,l2;
    JPanel p1,p2;
    JTextField tf1;
    JPasswordField tf2;
    public ex2()
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setTitle("Another example");
    setSize(500,500);
    setVisible(true);
    b1=new JButton(" ok ");
    p1=new JPanel();
    p1.setLayout(new GridLayout(2,2));
    p2=new JPanel();
    p2.setLayout(new BorderLayout());
    l1=new JLabel("Name :");
    l2=new JLabel("Password:");
    tf1=new JTextField(15);
    tf2=new JPasswordField(15);
    Container con=getContentPane();
    con.add(p1);
    con.add(p2);
    public static void createAndShowGUI()
    ex2.setDefaultLookAndFeelDecorated(true);
    public static void main(String ar[])
    createAndShowGUI();
    new ex2();
    }

    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class ex2 extends JFrame
        JButton b1;
        JLabel l1,l2;
        JPanel p1,p2;
        JTextField tf1;
        JPasswordField tf2;
        public ex2()
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            setTitle("Another example");
            b1=new JButton(" ok ");
            p1=new JPanel();
            p1.add(b1);
            p2=new JPanel();
            p2.setLayout(new GridLayout(2,2));
            l1=new JLabel("Name :");
            l2=new JLabel("Password:");
            tf1=new JTextField(15);
            tf2=new JPasswordField(15);
            p2.add(l1);
            p2.add(tf1);
            p2.add(l2);
            p2.add(tf2);
            Container con=getContentPane();
            con.add(p1, BorderLayout.NORTH);
            con.add(p2, BorderLayout.CENTER);
            pack();
            setVisible(true);
        public static void createAndShowGUI()
            ex2.setDefaultLookAndFeelDecorated(true);
        public static void main(String ar[])
            createAndShowGUI();
            new ex2();
    }

  • Vector, what is the problem with this code?

    Vector, what is the problem with this code?
    63  private java.util.Vector data=new Vector();
    64  Vector aaaaa=new Vector();
    65   data.addElement(aaaaa);
    74  aaaaa.addElement(new String("Mary"));on compiling this code, the error is
    TableDemo.java:65: <identifier> expected
                    data.addElement(aaaaa);
                                   ^
    TableDemo.java:74: <identifier> expected
                    aaaaa.addElement(new String("Mary"));
                                    ^
    TableDemo.java:65: package data does not exist
                    data.addElement(aaaaa);
                        ^
    TableDemo.java:74: package aaaaa does not exist
                    aaaaa.addElement(new String("Mary"));Friends i really got fed up with this code for more than half an hour.could anybody spot the problem?

    I can see many:
    1. i assume your code snip is inside a method. a local variable can not be declare private.
    2. if you didn't import java.util.* on top then you need to prefix package on All occurance of Vector.
    3. String in java are constant and has literal syntax. "Mary" is sufficient in most of the time, unless you purposly want to call new String("Mary") on purpose. Read java.lang.String javadoc.
    Here is a sample that would compile...:
    public class QuickMain {
         public static void main(String[] args) {
              java.util.Vector data=new java.util.Vector();
              java.util.Vector aaaaa=new java.util.Vector();
              data.addElement(aaaaa);
              aaaaa.addElement(new String("Mary"));
    }

  • What is the problem with this code ? Race condition??

    Guys,
    The idea behind the attached code is quite simple.
    I have a 2D parent array. First, I print a subset of this array into a table control (based on a sensor selection). Now, I want edit the numbers in the table. I need the changes to be reflected in the table and the parent 2D array. (In simple terms, this is like replacing the the edited array subset into the parent 2D array)
    The problem is when I change(edit) any entry in the table, the entry changes back to its original value. The change doesnt seem to be reflecting on the parent 2D array and the table. .
    Can anyone tell me where the problem is?
    Thanks
    Ravi
    Solved!
    Go to Solution.
    Attachments:
    Alarm threshold test.vi ‏14 KB

    I agree with Chris, here's an idea (of whatI think your code does):
    The case structure in your code was unnecessary, all the cases were the same so I removed them.
    The sequence structure was unnecessary.
    Ton
    Message Edited by TonP on 11-20-2008 07:52 PM
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!
    Attachments:
    Alarm threshold test_BD.png ‏19 KB

  • What is the problem with this code?

    dear sirs...
    i have a page that does not contain any binding, it contains the following event:
    public void onCheck(DataActionContext ctx)
    ViewObject V=ctx.getBindingContext.findDataControl("AppModuleDataControl").getApplicationModule.findViewObject("empview1");
    V.setWhereClause("");
    V.executeQuery();
    V.first();
    note that the above code works if the table emp is on the page, however, if the page is not bound to the page (it does not contains the table) the statement in the bold will fire an exception saying that there is no binding. i am sure the V is not set to null.
    another problem appears, if i put the table and execute it within jdeveloper, it works correctly, however, if i run if i deploy the application into application server, the code never runs as if there is some kind of an error.
    i hope that you can anser me about the following;
    1- if the code above correct?
    2- how can i view the log for the application?
    3- System.out.println("test"); in jdeveloper works okay, in the application server, does it cause some kind of an error?
    thanks for any help & best regards

    If you don't close the ResultSet, different things happen based on which database you're running. You can keep read locks that you don't need. It wastes resources, and as different databases react differently to it, you might have weird bugs down the road that result from your practices of not properly closing ResultSets, PreparedStatements, and Connections. Put this in a loop like you've got here, and the effects may or may not get amplified.
    I write a close() for a ResultSet just as soon as I open it, just to make sure I don't forget. In a situation like this one, I would write something like so:
    for(int i = 0;i<someValue;i++)
    try
    //some code
    rs = pstmt.executeQuery();
    //some code that uses rs
    catch(Exception e)
    finally
      if (rs != null)
        rs.close();
      if (pstmt != null)
        pstmt.close();
    }

  • "When_list_changed" what is the problem with this code???????

    DECLARE
         v_group_grade RECORDGROUP;
         v_pop_group NUMBER;
    BEGIN
         v_group_grade := find_group('group_grade');
         IF NOT id_null(v_group_grade) THEN
                   delete_group(v_group_grade);
         END IF;
         IF :CONTROL_LISTS.STAGE = 1 THEN
              v_group_grade := create_group_from_query('group_grade', 'SELECT grade_name FROM grade WHERE grade_name LIKE ''KG%''');
              v_pop_group := populate_group(v_group_grade);
              populate_list('CONTROL_LISTS.GRADE', v_group_grade);
         ELSIF :CONTROL_LISTS.STAGE = 2 THEN
              v_group_grade := create_group_from_query('group_grade', 'SELECT grade_name FROM grade WHERE grade_name LIKE ''Prim%''');
              v_pop_group := populate_group(v_group_grade);
              populate_list('CONTROL_LISTS.GRADE', v_group_grade);
         ELSIF:CONTROL_LISTS.STAGE = 3 THEN
              v_group_grade := create_group_from_query('group_grade', 'SELECT grade_name FROM grade WHERE grade_name LIKE ''Prep%''');
              v_pop_group := populate_group(v_group_grade);
              populate_list('CONTROL_LISTS.GRADE', v_group_grade);
         ELSE
              NULL;
         END IF;
    END;
    when I change the selection of the STAGE list in the runtime this error apear:
    FRM-41334 invalid record group for list population.

    Thanks Faheem,
    I got it it was in the select statement.
    When I create poplist to fetch data from the database I should select at least two charachter columns.

  • What is the error with this code ??

    i'm trying to execute the following AS3 code:
    var itemsArr:Array = new Array ();
    var i:int; 
          var loaderAds:URLLoader = new URLLoader();
          loaderAds.load(new URLRequest("ads.txt"));   
          loaderAds.addEventListener(Event.COMPLETE, completeHandlerAds);
          function completeHandlerAds(eventAds:Event):void {
              var loaderAds:URLLoader = URLLoader(eventAds.target);
              var varsAds:URLVariables = new URLVariables(loaderAds.data);
                itemsArr = varsAds.names.split(";");
                        for (i = 0; i < (itemsArr.length); i++) { 
                                trace("itemsArr, Processing: " + itemsArr[i]);
           var loaderProps:URLLoader = new URLLoader();
          loaderProps.load(new URLRequest(itemsArr[i]+".txt"));   
          loaderProps.addEventListener(Event.COMPLETE, completeHandlerProps);
          trace("one: " + itemsArr[i]);
          function completeHandlerProps(eventProps:Event):void {
                  trace("two: " + itemsArr[i]);
          }// end of fn for props
                        }//end of "for" loop of ads names
            }//end of fn for ads names
    But i get the following output:
    adsNames Array: ad0,ad1
    adsNames, Processing: ad0
    ad0
    adsNames, Processing: ad1
    ad1
    null
    TypeError: Error #2007: Parameter name must be non-null.
         at flash.display::DisplayObject/set name()
         at MethodInfo-279()
         at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunctio  n()
         at flash.events::EventDispatcher/dispatchEvent()
         at flash.net::URLLoader/flash.net:URLLoader::onComplete()
    null
    TypeError: Error #2007: Parameter name must be non-null.
         at flash.display::DisplayObject/set name()
         at MethodInfo-279()
         at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunctio  n()
         at flash.events::EventDispatcher/dispatchEvent()
         at flash.net::URLLoader/flash.net:URLLoader::onComplete()
    As you see, the "red text" is errors, Can you tell me the reason for it ?
    And also, tracing "itemsArr[i]" in the second time, always give "null", also in the first time, it give the correct value, Why ?

    the red text not appear after i posted the topic, but you can see the errors on the output
    and, you've to create to text files, first called "ads.txt" and put in it "names=ad0;ad1"
    second one called "ad0.txt" and put anything in it, and another called "ad1.txt" and put anything in it
    all these files should be in the same dir of flash file

  • What's the problem in this code

    import java.lang.reflect.*;
    import java.awt.*;
    class ABC
         public Integer i;
         ABC()
         public void setInt(Integer t)
              i = t;
    public class SampleName {
    public static void main(String[] args)
    ABC g1 = new ABC();
    g1.setInt(new Integer(10));
    printFieldNames(g1);
    static void printFieldNames(Object o) {
    Class c = o.getClass();
    Field[] publicFields = c.getDeclaredFields();
    for (int i = 0; i < publicFields.length; i++)
    try {
    Object ref = publicFields.get(c);
    System.out.println(" ref.toString() : " + ref.toString());
         }catch(Exception e)
                   e.printStackTrace();
    What is the problem with this code,at run time Iam getting this exception
    java.lang.IllegalArgumentException: object is not an instance of declaring class
    How can we get the value of field of an object

    Now it got this exception
    java.lang.IllegalAccessException
    at java.lang.reflect.Field.get(Native Method)That's strange - I didn't! ;-)
    Are you running exactly the same code as the code you posted (except for the one line I said to change)?

  • My computer died and I had to buy another one.  Now I can't sync my ipod classic.  What is the deal with this?  I added songs about three months ago and it was fine.  Now it won't sync.  It says it has a duplicate file.

    My computer died and I had to buy another one.  Now I can't sync my ipod classic.  What is the deal with this?  I added songs about three months ago and it was fine.  Now it won't sync.  It says it can't sync because there is a duplicate file.

    There are server problems right now with iMessage effecting some users.  See http://www.apple.com/support/icloud/systemstatus/.

  • What's the go with this latest update. Half my apps don't work and the iPad runs slower? How do I go back to the old operating system?

    What's the go with this latest update. Half my apps don't work and the iPad runs slower? How do I go back to the old operating system?

    Make sure your apps are updated.  You might try Settings > iTunes & App Store > Automatic Downloads - Updates = "On".
    You cannot go back to an old operating system.

  • HT202213 My apple TV no longer finding my movies and photos. What's the deal with this?

    My apple TV no longer finding my movies and photos. What's the deal with this?

    That would be awesome, if the nearest service area wasn't 4 hours away.... It would cost me just as much in gas to drive down there as it would just to buy a cheap replacement off of ebay...

  • Trying to set up a linksys router but the cd says it works with OSX 10.6 and later. I am currently running the newest version of mountain lion.... what is the matter with this OSX   update needed?

    trying to set up a linksys router but the cd says it works with OSX 10.6 and later. I am currently running the newest version of mountain lion.... what is the matter with this OSX   update needed?

    Your install disk must look like this
    and not like this.
    Those gray disks are machine specific and will only work with model of Mac that they shipped with.

  • What is the deal with this thing?

    My computer no longer recognizes my ipod mini, won't charge it, or anything. It isn't responding to anything. I have tried resetting it so many times. All it does is show the "Do not disconnect." screen, and the backlight turns on when I press a button on the click wheel. My computer does not acknowledge that the ipod is connected to it at all, so I just diconnected it. However, the screen still says the same thing! I cannot find anyway to get some help off the Apple site. There are e-mail addresses or anything, which is completely annoying. My ipod mini is 13 months old and cost way too much money for this to be happening. Is it lost for good? What is the deal with this thing? Seriously, please help.

    First of all, try another port on your computer. Some ports are not connected direct to the motherboard and do not recognize the iPod as well as those that are. Reset the iPod each time you connect it to another port.
    Still no joy, see these.
    Your Windows PC doesn't recognize iPod.
    iPod appears in Windows Explorer but does not appear in iTunes.
    iPod does not appear in iTunes.
    Fast user switching in Windows XP is not supported.
    Strange iPod behavior.
    When restoring the iPod, put it into disk mode first.
    Putting iPod into disk mode.

  • What is the deal with this frekin battery life, it wont even make it through a 10 hour work day, very angry with this iphone 4s

    what is the deal with this freaking short battery life it is far less then apple advertises, This is pathetic....I bought this phone because it was advertised,....  to be the best on the market ...........................any suggestions?

    Wait for the software update that Apple has already said will be coming in a few weeks.

  • I was playing candy crush and I had too much problem with my bill your charge too much I want to know what is the problem with this game cost

    HELLO
    I was playing candy crush and I had too much problem with my bill your charge too much I want to know what is the problem with this game cost

    Take it up with iTunes Support - we are not Apple here, we are just users like you:
    http://www.apple.com/support/itunes/ww/
    Cheers,
    GB

Maybe you are looking for