Preparedstatement - please test this code!!

I hope someone can test this code and tell me if it works. It seems to work on my computers (win98 and win2000, and access 2002 database, compiling etc,and even returns that it updated 1 record. But the database is unchanged. Commit is default to autocommit, what else could be causing this? None of the setxxx commands work. Yet no errors are given. Please test and let me know. Or, send me similar simple code that works on an access 2002 database from win98 or 2000. I am wondering if access 2002 has something to do with this. I am using default ODBC driver that came with the OS.
Thank you,
Jacques
import java.sql.*;
import java.io.*;
public class test {
static Driver d;
static Connection conn;
final static String jdbcDriver="sun.jdbc.odbc.JdbcOdbcDriver";
static String databaseURL = "jdbc:odbc:" + "dbtest";
public static void main(String[] args) {
try {
d = (Driver) Class.forName(jdbcDriver).newInstance();
conn = DriverManager.getConnection(databaseURL);
PreparedStatement stmt = conn.prepareStatement(
"UPDATE employee SET emp_id = ? WHERE Index = ?");
stmt.setString( 1, "John" );
stmt.setInt( 2, 2);
System.out.println("about to update");
int count = stmt.executeUpdate();
System.out.println("number updated=" + count);
catch( Exception e ){
System.out.println("Error:" + e);
Database: Set up access database with table employee at least 2 records, one field called emp_id, register it in odbc as dbtest

Ok, for anyone else that encounters this, I found the answer! After a week of very frustrating testing, I stuck in a close() to the connection, and the changes were then actually made. I had counted on Java to close them properly upon exit, but I must specify the conn.close() after the executeUpdate before they take effect. Another weird worm of Java IMHO.

Similar Messages

  • Could you please check this code

    Hi There,
    The scenario here is :
    I have written this piece of code but its not showing desired result .I think the problem is in the AVGRANGE.
    Please look into this and let me know if I am doing anything wrong.
    I need to accomplish this task ,if employee E1 & E2 are in Entity1 in Grade S in forecast1 and now in forecast 2 a new employee namely E3 has come in this new forecast and whether he belongs to same entity can be identified by a new account say "F",If "F" is present for that Employee in that particular entity means he belongs to that Entity .Then I need to calculate.
    "P" value for E3 for a month=Avg of "P" value for E1 & E2 in Entity1 in Grade S for that month.
    I think this code is calculating for invalid combination also.
    FIX (&CurrFctScenario,&CurrFctVersion,&CurrYear)
    FIX (&SeedCurrency)
    FIX(@descendatns("Entity"),@descendatns(GRADE),@Descendants(Employee)
    FIX (&CurrMonth:"MAY"
    , &SeedHSP
    "P"(
    IF ( "F"!=#Missing AND "P"==#Missing)
    @AVGRANGE(SKIPNONE,"P",@children(Employee)->@currmbr(Grade)->@currmbr(entity));
    ENDIF;
    ENDFIX
    ENDFIX
    One more thing as I am testing this code for say two three employees then its working fine but as I am uisng @children(Employee) then I am getting error message
    Error: 1012704 Dynamic Calc processor cannot lock more than [200] ESM blocks during the calculation, please increase CalcLockBlock setting and then retry(a small data cache setting could also cause this problem, please check the data cache size setting).
    Is there any other way of doing this calculation?
    Edited by: user10760185 on Jun 1, 2011 5:35 AM

    Thanks a lot Alp...
    Please find the logic of the calculation below:
    In forecast1,here E1=employee,S1=Grade,P1=Account member
    E1->S1->Entity1->P1= 100
    E2->S1->Entity1->P1=200
    In forecast2,E3,a new employee has come and if he/she belongs to S1 and Entity1 ,then the value should be
    If (E3->F!->@currmbr(grade)->@currmbr(entity)=#Missing AND P1==#Missing)
    E3->S1->Entity1->P1= (100+200)/2
    I will read the document and will check my cache settings.
    Edited by: user10760185 on Jun 1, 2011 11:36 PM

  • Can anyone please explain this code to me?

    I am a new (junior)programmer?Can anyone please explain this code to me in lame terms? I am working at a client location and found this code in a project.
    _file name is AtccJndiTemplate.java_
    Why do we use the Context class?
    Why do we use the properties class?
    package org.atcc.common.utils;
    import java.io.IOException;
    import java.io.InputStream;
    import java.util.Properties;
    import java.util.logging.Logger;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import org.springframework.jndi.JndiTemplate;
    public class AtccJndiTemplate extends JndiTemplate
      private static Logger logger = Logger.getLogger(AtccJndiTemplate.class.getName());
      private String jndiProperties;
      protected Context createInitialContext()
        throws NamingException
        Context context = null;
        InputStream in = null;
        Properties env = new Properties();
        logger.info("Load JNDI properties from classpath file " + this.jndiProperties);
        try
          in = AtccJndiTemplate.class.getResourceAsStream(this.jndiProperties);
          env.load(in);
          in.close();
        catch (NullPointerException e) {
          logger.warning("Did not read JNDI properties file, using existing properties");
          env = System.getProperties();
        } catch (IOException e) {
          logger.warning("Caught IOException for file [" + this.jndiProperties + "]");
          throw new NamingException(e.getMessage());
        logger.config("ENV: java.naming.factory.initial = " + env.getProperty
    ("java.naming.factory.initial"));
        logger.config("ENV: java.naming.factory.url.pkgs = " + env.getProperty
    ("java.naming.factory.url.pkgs"));
        logger.info("ENV: java.naming.provider.url = " + env.getProperty
    ("java.naming.provider.url") + " timeout=" + env.getProperty("jnp.timeout"));
        context = new InitialContext(env);
        return context;
      public String getJndiProperties()
        return this.jndiProperties;
      public void setJndiProperties(String jndiProperties)
        this.jndiProperties = jndiProperties;
    }

    Hi,
    JNDI needs some property such as the
    java.naming.factory.initial
    java.naming.provider.url
    which are needed by the
    InitialContext(env);
    where env is a properties object
    Now if you can not find the physical property file on the class path
    by AtccJndiTemplate.class.getResourceAsStream(this.jndiProperties);
    where the String "jndiProperties" get injected by certain IOC ( inverse of control container ) such as Spring framework
    if not found then it will take the property from the system which will come from the evniromental variables which are set during the application start up i.e through the command line
    java -Djava.naming.factory.initial=com.sun.jndi.ldap.LdapCtxFactory -Danother=value etc..
    I hope this could help
    Regards,
    Alan Mehio
    London,UK

  • Could somebody please test this app on Apple TV?

    Hi,
    Wifey is interested in getting Apple TV gen2, but only if the following App works with it.
    She wants to stream video from YOUKU HD (the app name) from IPAD 2 to our bedroom TV using Apple TV.
    Would somebody please test this app to see if it streams ok or not via Airplay?
    It is a free app.
    Please and thank you to anyone who could assist.
    Must be IPAD2
    Must be You KU HD
    Must be Apple TV 2nd generation.
    Kind regards,
    Chris.

    Mrharrod wrote:
    Hi,
    Dodgy? lol
    Never thought of it like that, but to answer your question, yes YOU KU is a kind of YouTube but in China.
    Is it legal, yes it is from what I know. It only has chinese content from what I have seen.
    In itunes one of the screenshots has a Tom & Jerry cartoon which I suspect is copyrighted material, and it specifically says it has copyrighted material though something may have been lost in translation. (Species-specific content - is that TV for the cat/dog/hamster ;-) )
    If they are offering copyrighted material streaming for free it sounds dodgy though it may not be of course.
    When I mentioned polarised ratings it seems to have about 50/50 1 star vs 5 star ratings in itunes.
    AC

  • Please explain this code,this is regarding to ODS activation.

    Hi,
        Please I am unable to understand this code,this exists initial activation of ODS,please can anyone please explain me this
    ob started
    Step 001 started (program RSPROCESS, variant &0000000055152, user ID ALEREMOTE)
    Activation is running: Data target ZYL_O82, from 1.165.349 to 1.165.349
    Data to be activated successfully checked against archiving objects
    SQL: 20.06.2007 05:34:26 ALEREMOTE
    ANALYZE TABLE "/BIC/AZYT_O6240" DELETE STATISTICS
    SQL-END: 20.06.2007 05:34:26 00:00:00
    SQL: 20.06.2007 05:34:26 ALEREMOTE
    BEGIN DBMS_STATS.GATHER_TABLE_STATS ( OWNNAME =>
    'SAPR3', TABNAME => '"/BIC/AZYT_O6240"',
    ESTIMATE_PERCENT => 1 , METHOD_OPT => 'FOR ALL
    INDEXED COLUMNS SIZE 75', DEGREE => 1 ,
    GRANULARITY => 'ALL', CASCADE => TRUE ); END;
    Thanks & Regards,
    Mano

    Hi,
        Please I am unable to understand this code,this exists initial activation of ODS,please can anyone please explain me this
    ob started
    Step 001 started (program RSPROCESS, variant &0000000055152, user ID ALEREMOTE)
    Activation is running: Data target ZYL_O82, from 1.165.349 to 1.165.349
    Data to be activated successfully checked against archiving objects
    SQL: 20.06.2007 05:34:26 ALEREMOTE
    ANALYZE TABLE "/BIC/AZYT_O6240" DELETE STATISTICS
    SQL-END: 20.06.2007 05:34:26 00:00:00
    SQL: 20.06.2007 05:34:26 ALEREMOTE
    BEGIN DBMS_STATS.GATHER_TABLE_STATS ( OWNNAME =>
    'SAPR3', TABNAME => '"/BIC/AZYT_O6240"',
    ESTIMATE_PERCENT => 1 , METHOD_OPT => 'FOR ALL
    INDEXED COLUMNS SIZE 75', DEGREE => 1 ,
    GRANULARITY => 'ALL', CASCADE => TRUE ); END;
    Thanks & Regards,
    Mano

  • How to test this code ???

    Hi All,
    One quick question:
    ..>>>>How do you test below InterfaceImpl classes in a simple program to test the code ???
    //below is the sample of the example I am running .
    Thanks
    Jack
    //interface 1
    same package;
    interface someInterfaceName1 {
    public void setLastName();
    public String getLastName();
    //inerface 2
    same package;
    interface someInterfaceName2{
    public void setBillingAddress(somename1 billing){
    public void setShippingAddress(somename1 shipping){
    // implementation class1
    samepackage;
    public class someInterfaceName1Impl implements someInterfaceName1 {
    private String lastName="";
    someInterfaceName1Impl();
    public void setLastName(String lastName){
    this.lastName=lastName;
    public String getLastName(){
    return LastName;
    //implementatio class2 for interface 2
    samepackage;
    class someInterfaceName2Impl implements someInterfaceName2
    public void setBillingAddress(interface1 billto){
    billto.setlastName(someValue); --?????
    public void setShippingAddress(interface1 shipto) {
    shipto.setFirstName(someValue); --- ?????
    //How to test the code ??
    package samepackage;
    class testMyCode {
    public static void main(String args[]){
    // how do you get the interfaces implementation here to test with dummy values ????

    Something along these lines (but departing from your code a bit...) public static void test() {
        Interface1 ifc1 = new Impl1();
        String tmpStr;
        int tmpInt;
        ifc1.setName("joe");
        tmpStr = ifc1.getName();
        if (!("joe".equals(tmpStr))) {
            System.err.println("set/getName failed. Put in joe but got out " + tmpStr);
        ifc1.setBirthdate("May 1 1980");
        tmpInt = ifc1.getAge();
        if (tmpInt != 24) {
            System.err.println("setBirthdate/getAge failed. Put in May 1 1980, expected 24 but got " + tmpInt);
        try {
            tmpStr = "Booger 99, 19seventy-beer";
            ifc1.setBirthdate(tmpStr);
            //shouldn't get here
           System.err.println("setBirthdate accepted invalid date: " + tmpStr);
        catch (InvalidBirthdateException exc) {
            // we want this, since it means our code properly rejected a bad date
    } Or, when you start writing serious code, look into junit
    ジ

  • Can someone please proof this code writing to my db...

    i have this code that was working and i moved it around a
    little and now i'm getting errors when it tries to write to the db.
    if the user enters a valid credit card number (basic check that
    i've tested and i know this part works fine but still wanted to
    show all the code) it is supposed to write all the info from the
    previous page's form into the db. i'm sure it's something small and
    stupid, but i need to get this up and running immediately.
    thanks in advance for any help...

    A side note, you're storing unencrypted credit card
    information in your database and this is a violation of the credit
    card regulations (
    PCI).
    Because of the liability factor, I suggest that you do not store
    credit card information at all and instead use some form of
    Tokenization
    (different providers call it different names). At the very minimum,
    if you don't use tokenization or something similar, you MUST
    encrypt the data with a 128bit encryption method of better (3DES,
    Blowfish, AES, etc.).

  • Regarding color picking and color management - can someone, please test this?

    Please take a few seconds to test this and let me know the result.
    This is with CS5 but probably the same with older versions:
    Create a new document and zoom out so that the canvas is smaller than the window.
    Change the Standard Screen Mode color to Custom and choose some color, for example gray that is 60 for each R,G, and B.
    You can do that in the Interface page of the Preferences or by right clicking on the empty area of the window that is beyond the image's canvas.
    Using the eyedropper tool pick the color of that empty area
    Press Alt + Delete to fill the canvas with that color.
    Do you see a difference between the canvas and that area.
    I see a slight difference when the color management preview is on and no difference when it is off (soft proofing using Monitor RGB)
    I have some ideas but it will be great of someone can make a clear conclusion and explanation for this behavior.

    Thanks for that confirmation, Chris.
    Same thing with my apps, though with effort I suppose the colors for the controls and background COULD be put through the color management system at startup time...  Lots more complexity though, and that would kind of diverge with the concept of theme selection, not to mention potentially uncovering bugs in the control implementations...  And, if the user has gone out of his way to set everything to a pretty shade of blue, and along comes a color-managed dialog that's gone greenish because that's what those color values REALLY mean, that would likely be reported as a bug just because it's different...
    -Noel

  • Please help, this code is trashing the database

    I have the 'pleasure' of fixing a view that as you can see in poorly written, and it is in production.
    This thing is dying in production is giving me ORA-03113: end-of-file on communication channel error, I did my research and it is a patch that the DBA needs to apply, but he is telling that he does not have time, anyway, if someone out there kindly look at this code and give me some hints of how I can fix this thing, If you look at the end of the code where I put the message 'here is the problem; it is with this thing is dying, It does not like that subquery, I put alias on the tables but still not working.
    SELECT y.gtvsdax_internal_code, y.gtvsdax_internal_code_group,
    spraddr_pidm, spriden_id, spriden_last_name, spriden_first_name,
    spriden_mi, spraddr_atyp_code, stvatyp_desc, spraddr_street_line1,
    spraddr_street_line2, spraddr_street_line3, spraddr_city,
    spraddr_stat_code, stvstat_desc, spraddr_zip, spraddr_cnty_code,
    stvcnty_desc, spraddr_natn_code, stvnatn_nation, spraddr_seqno,
    spraddr_delivery_point, spraddr_correction_digit
    FROM saturn.stvatyp, saturn.stvnatn, saturn.stvstat, saturn.stvcnty, saturn.spriden, saturn.spraddr x, general.gtvsdax y
    WHERE y.gtvsdax_internal_code_group = 'CC_ADDRESS_SYVADDS'
    AND x.spraddr_seqno =
    (SELECT MAX (spraddr_seqno)
    FROM spraddr a
    WHERE a.spraddr_pidm = x.spraddr_pidm
    AND a.spraddr_atyp_code = x.spraddr_atyp_code
    AND a.spraddr_status_ind IS NULL
    AND ( (a.spraddr_to_date IS NULL
    AND a.spraddr_from_date IS NULL
    OR ( a.spraddr_to_date IS NOT NULL
    AND a.spraddr_from_date IS NOT NULL
    AND TRUNC (SYSDATE) BETWEEN TRUNC (a.spraddr_from_date)
    AND TRUNC (a.spraddr_to_date)
    OR ( a.spraddr_from_date IS NOT NULL
    AND a.spraddr_to_date IS NULL
    AND TRUNC (SYSDATE) >= TRUNC (a.spraddr_from_date)
    OR ( a.spraddr_from_date IS NULL
    AND a.spraddr_to_date IS NOT NULL
    AND TRUNC (SYSDATE) <= TRUNC (a.spraddr_to_date)
    AND stvatyp_code(+) = x.spraddr_atyp_code
    AND stvnatn_code(+) = x.spraddr_natn_code
    AND stvstat_code(+) = x.spraddr_stat_code
    AND stvcnty_code(+) = x.spraddr_cnty_code
    AND spriden_pidm = x.spraddr_pidm
    AND spriden_change_ind IS NULL
    AND x.spraddr_status_ind IS NULL
    AND ( (x.spraddr_to_date IS NULL AND x.spraddr_from_date IS NULL)
    OR ( x.spraddr_to_date IS NOT NULL
    AND x.spraddr_from_date IS NOT NULL
    AND TRUNC (SYSDATE) BETWEEN TRUNC (x.spraddr_from_date)
    AND TRUNC (x.spraddr_to_date)
    OR ( x.spraddr_from_date IS NOT NULL
    AND x.spraddr_to_date IS NULL
    AND TRUNC (SYSDATE) >= TRUNC (x.spraddr_from_date)
    OR ( x.spraddr_from_date IS NULL
    AND x.spraddr_to_date IS NOT NULL
    AND TRUNC (SYSDATE) <= TRUNC (x.spraddr_to_date)
    here is the problem
    AND ((y.gtvsdax_internal_code_seqno||y.gtvsdax_external_code,
    x.spraddr_atyp_code
    ) =
    (SELECT MIN (c.gtvsdax_internal_code_seqno
    ||c.gtvsdax_external_code
    MIN (c.gtvsdax_external_code)
    FROM saturn.spraddr m, general.gtvsdax c
    WHERE c.gtvsdax_internal_code = y.gtvsdax_internal_code
    AND c.gtvsdax_internal_code_group = y.gtvsdax_internal_code_group
    AND m.spraddr_pidm = x.spraddr_pidm
    AND m.spraddr_atyp_code = c.gtvsdax_external_code
    AND m.spraddr_status_ind IS NULL)
    AND ( (x.spraddr_to_date IS NULL
    AND x.spraddr_from_date IS NULL
    OR ( x.spraddr_to_date IS NOT NULL
    AND x.spraddr_from_date IS NOT NULL
    AND TRUNC (SYSDATE) BETWEEN TRUNC (x.spraddr_from_date)
    AND TRUNC (x.spraddr_to_date)
    OR ( x.spraddr_from_date IS NOT NULL
    AND x.spraddr_to_date IS NULL
    AND TRUNC (SYSDATE) >= TRUNC (x.spraddr_from_date)
    OR ( x.spraddr_from_date IS NULL
    AND x.spraddr_to_date IS NOT NULL
    AND TRUNC (SYSDATE) <= TRUNC (x.spraddr_to_date)
    ))

    Agreed on formatting the query nicely.
    The bit that jumped out to my problem-spotting eye was
    AND ( (a.spraddr_to_date IS NULL
       AND a.spraddr_from_date IS NULL
    OR ( a.spraddr_to_date IS NOT NULL
       AND a.spraddr_from_date IS NOT NULL
       AND TRUNC (SYSDATE) BETWEEN TRUNC (a.spraddr_from_date)
       AND TRUNC (a.spraddr_to_date)
    OR ( a.spraddr_from_date IS NOT NULL
    AND a.spraddr_to_date IS NULL
    AND TRUNC (SYSDATE) >= TRUNC (a.spraddr_from_date)
    OR ( a.spraddr_from_date IS NULL
    AND a.spraddr_to_date IS NOT NULL
    AND TRUNC (SYSDATE) <= TRUNC (a.spraddr_to_date)
    ))which could be written as
    AND trunc(sysdate) BETWEEN trunc(nvl(a.spraddr_from_date, sysdate))
                           AND trunc(nvl(a.spraddr_to_date, sysdate))Similarly with x.spraddr_from_date/to_date.

  • Can someone please test this widget?

    Hi,
    (sorry if this is in the wrong forum but I couldn't find a better place)
    Can someone please try this widget?
    http://www.apple.com/downloads/dashboard/information/speciesdistributionmap.html
    The map shows on 2 out of 3 of the macs in the office but we can't determine why it doesn't work on the third... If you can see the map, then it works. We can't spot any difference in the settings on the machines
    Many many thanks!
    Tim

    I have the i7-720 and the processor and I can attest to the W510 overheating. I recently had my planar replaced under warranty and it returned with an overheating issue for heavy processor loads.  This overheating was resolved by properly applying thermal paste (lenovo applied about 3x as much as was needed)  while the GPU continues to overheat and cause stuttering. If I run furmark in any resolution for a length of time at maximum fan speed and watch the GPU overheat, throttle, and overheat again. This would all be fine if it didn't cause the whole system to lag terribly in games or on the desktop.
    In my view the design of the GPU cooler and thermal pads for the GPU memory cooling are very sensitive to installation. The cooler is easy to bend and the pressure clamp for the GPU isn't really designed to a certain tolerance. It's simply a clamp with a bent part that will apply some random amount of pressure to the gpu cooler.
    It's just such a delicate system of cooling that there is too much room for error. It has to be installed correctly in order to function properly and I don't think there is really a good way of making sure that you've done it without running benchmarks for hours after reinstalling the cooler. I don't think this is something Lenovo is going to do. There aren't any options from Lenovo for a better heat sink design and I am pretty sure not everyone is having these issues.
    So I'm going to mess with the GPU cooler until it starts working. Here's a furmark screenshot showing the temps.
    Link to picture
    Moderator note; picture(s) totalling >50K converted to link(s) Forum Rules

  • Please fix this code.

    Can anyone please fix this, it in not drawing the polygons.
    import chn.util.*;
    import java.awt.geom.*;  // for Point2D.double
    import java.util.*;      // for ArrayList
    import apcslib.*;        // for DrawingTool
    public class Irregular_Polygon 
         private ArrayList myPolygon = new ArrayList(10);
           public static void main (String [ ] args)
                Irregular_Polygon myIrregularPolygon = new Irregular_Polygon();
            // constructors
            public Irregular_Polygon()
                ConsoleIO keyboard = new ConsoleIO();
                 System.out.println("Enter amount of vertices");
                 int vertices = keyboard.readInt();
                 for (int s = 1; s <= vertices; s++)
                    System.out.print("x coordinate");
                    double x = keyboard.readDouble();
                    System.out.print("y coordinate");
                    double y = keyboard.readDouble();
                    Point2D.Double myPoint = new Point2D.Double(x,y);
                    add(myPoint);
             draw();
       // public methods
       public void add(Point2D.Double aPoint)
              myPolygon.add(aPoint); 
       public void draw()
             DrawingTool pencil;
               SketchPad paper;
               paper = new SketchPad(500, 500);
             pencil = new DrawingTool(paper);
               pencil.up();
               int p = 0;
               for (p = 0; p < myPolygon.size() - 1; p++);
                   Point2D.Double ptA = (Point2D.Double)myPolygon.get(p);
                   double x = ptA.getX();
                   double y = ptA.getY();
                   pencil.move(x * 100,y * 100);
                   pencil.down();
      // public double perimeter()
      // public double area()

    Can anyone please fix this, it in not drawing the
    polygons.No, you do your own work, and ask specific questions as needed.

  • Please explain this code to me (in English)!  Thanks.

    Hello everyone,
    I am working with some AS3 code that someone else has written.  The code creates datatables and populates them by pulling from a .NET webservice using SOAP and DataTables.
    I have copied and pasted the code below.  Most of it makes sense and I understand it, however, there are some things I've never seen before and have not been able to find on the internet.  Most of the things I have a problem with, I've created comments in ALL CAPS with my questions.
    If someone could take a look at it and tell me what is going on I would appreciate it.
    Thanks.
                  //Load result data into XMLList structure
                  var xmlData:XML = XML(myService.GetViewResults.lastResult);
                  //gets the DataTables data, length of tableXML is the number of Tables you got
                  var tableXML:XMLList = xmlData.GetViewResultsResult.DataTables.children();
                  //gets the number of tables returned in the result
                  var numTables:int = tableXML.children().length();
                  //seperates out the data for each table
                  var tempXMLArray:Array = new Array();
                  var tempXML:XML;
                  for (var i:int=0; i<numTables; i++)
                      tempXML = tableXML[i];
                      tempXMLArray.push(tempXML);
                  //create a datagrid for each table
                  var datagrid1:DataGrid, datagrid2:DataGrid, datagrid3:DataGrid;
                  //create array collections to feed datagrids
                  var ac1:ArrayCollection, ac2:ArrayCollection, ac3:ArrayCollection;
                  var currentTableXML:XML;
                  var columns:Array = new Array();
                  var dgc:DataGridColumn;
                  var obj:Object;  // WHY IS THIS OBJECT NEEDED?
                  //CREATING TABLE 1
                  currentTableXML = tempXMLArray[0];
                  datagrid1 = new DataGrid();
                  datagrid1.width = 1000;
                  datagrid1.height = 200;
                  datagrid1.y = 0;
                  columns = new Array();
                  for (i=0; i<currentTableXML.Columns.children().length(); i++)
                      dgc = new DataGridColumn(currentTableXML.Columns.NHRCViewResultColumn.ColumnName[i].toString());
                      dgc.dataField = currentTableXML.Columns.NHRCViewResultColumn.ColumnName[i];
                      columns.push(dgc);
                  datagrid1.columns = columns;
                  ac1 = new ArrayCollection;
                   // looping through each piece of data in the row
                   for (i=0; i<currentTableXML.Rows.children().length(); i++)
                      trace("table 1:creating row " + i);
                   // I HAVE NO IDEA WHATS GOING ON HERE... WHAT IS THIS OBJECT DOING EXACTLY?
                      obj = {
                             // I DON'T UNDERSTAND THIS SYNTAX - WHAT ARE THE COLONS FOR???  AND WHY STORE IN AN OBJECT???
                          ((datagrid1.columns[0] as DataGridColumn).dataField.toString()):(currentTableXML.Rows.NHRCViewResultRow.Values[i].string[0]),
                          ((datagrid1.columns[1] as DataGridColumn).dataField.toString()):(currentTableXML.Rows.NHRCViewResultRow.Values[i].string[1]),
                          ((datagrid1.columns[2] as DataGridColumn).dataField.toString()):(currentTableXML.Rows.NHRCViewResultRow.Values[i].string[2]),
                          ((datagrid1.columns[3] as DataGridColumn).dataField.toString()):(currentTableXML.Rows.NHRCViewResultRow.Values[i].string[3]),
                          ((datagrid1.columns[4] as DataGridColumn).dataField.toString()):(currentTableXML.Rows.NHRCViewResultRow.Values[i].string[4]),
                          ((datagrid1.columns[5] as DataGridColumn).dataField.toString()):(currentTableXML.Rows.NHRCViewResultRow.Values[i].string[5])
                      ac1.addItem(obj);
                  datagrid1.dataProvider = ac1;
                  this.addChild(datagrid1);  //Adding populated datagrid to the screeen

    The following code creates a variable obj of type Object. You need to declare the variable, and you don't want to do that inside the loop where the object is constructed, because then it will be scoped within the loop block, so it is first declared outside the loop.
    var obj:Object;  // WHY IS THIS OBJECT NEEDED?
    Now you are constructing the object. Here is the logic of what is going on.
    Objects of this type in Flex are constructed as follows:
    objName = {
      fieldName1: fieldVal1,
      fieldName2: fieldVal2,
      fieldName3: fieldVal3
    In this code, the field names are:
    (datagrid1.columns[0] as DataGridColumn).dataField.toString()
    and you need to cast as DataGridColumn first.
    The field values are:
    (currentTableXML.Rows.NHRCViewResultRow.Values[i].string[0])
    So here it seems you are taking the first item in the string element of the ith element of Values, which is obtained by parsing into the currentTableXML, Rows element, NHRCViewResultRow element.
    // I HAVE NO IDEA WHATS GOING ON HERE... WHAT IS THIS OBJECT DOING EXACTLY?
                      obj = {
                             // I DON'T UNDERSTAND THIS SYNTAX - WHAT ARE THE COLONS FOR???  AND WHY STORE IN AN OBJECT???
                          ((datagrid1.columns[0] as DataGridColumn).dataField.toString()):(currentTableXML.Rows.NHRCViewResultRow.V alues[i].string[0]),
                          ((datagrid1.columns[1] as DataGridColumn).dataField.toString()):(currentTableXML.Rows.NHRCViewResultRow.V alues[i].string[1]),
                          ((datagrid1.columns[2] as DataGridColumn).dataField.toString()):(currentTableXML.Rows.NHRCViewResultRow.V alues[i].string[2]),
                          ((datagrid1.columns[3] as DataGridColumn).dataField.toString()):(currentTableXML.Rows.NHRCViewResultRow.V alues[i].string[3]),
                          ((datagrid1.columns[4] as DataGridColumn).dataField.toString()):(currentTableXML.Rows.NHRCViewResultRow.V alues[i].string[4]),
                          ((datagrid1.columns[5] as DataGridColumn).dataField.toString()):(currentTableXML.Rows.NHRCViewResultRow.V alues[i].string[5])

  • Menu processing - Please condense this code

    Well I have a menu on Frame1 of the main stage with 5
    movieclips as the menu bars. Pressing the 1st menu should move the
    frame of the main stage one postition (to frame2). Pressing the 2nd
    menu should take you to frame3 of the main stage. Etc, etc.
    Anytime I put the 'gotoAndStop(2)' directly into the
    eventlistener line, that function is run upon testing the
    application. So, when testing the app, it starts at Frame2 instead
    of frame1 and nothing was clicked.
    So can anybody explain why this attached code works, but why
    any other method doesn't? in noob terms?
    Thanks

    Menu1Click, for example, is the name of a function.
    Menu1Click() is a function call. ie, you'll execute that
    function's code immediately after the function name followed by ()
    is executed.
    likewise, if you use the goto methods.

  • Any one  please correct  this code it is not giving the result as expected.

    class image {
         public int[][] data;
         public int rows;
         public int columns;
    public class BlurImage {
    public int function1(image i1,int k,int j,int rad)
                   int sum=0;
                   int count=0;
                   int R=0,G=0,B=0;
                   String s=new String();
                   for(int x=k-rad;x<=k+rad;x++)
                        if(x<0 || x>=i1.rows)
                             continue;
    for(int y=j-rad;y<=j+rad;y++)
                             if(y<0 || y>=i1.columns)
                                  continue;
    s=Integer.toHexString(i1.data[x][y]).substring(4,6);
                             B=B+Integer.valueOf(s, 16).intValue();
                             s=Integer.toHexString(i1.data[x][y]).substring(2,4);
                             G=G+Integer.valueOf(s, 16).intValue();
                             s=Integer.toHexString(i1.data[x][y]).substring(0,2);
                             R=R+Integer.valueOf(s, 16).intValue();
    count++;
                   R=R/count;
                   G=G/count;
                   B=B/count;
                   System.out.println(" ");
                   String s1=new String();
                   s1=Integer.toHexString(R).concat(Integer.toHexString(G));
                   s1=s1.concat(Integer.toHexString(B));
                   System.out.println(Integer.valueOf(s1, 16).intValue()+" ");
                   return Integer.valueOf(s1, 16).intValue();
    public image blur_image(image i, int radius) {
              //Write your code here
              if(i.rows<radius || i.columns<radius)
                   return null;
              image i1 = new image();
              i1.rows=i.rows;
              i1.columns=i.columns;
              i1.data=new int[i.rows+1][i.columns+1];
              for (int k = 0; k < i.rows; k++)
              for (int j = 0; j < i.columns; j++)
                        if(i.data[k][j]>0xFFFFFF)
                             return null;
                        i1.data[k][j]=(int)function1(i,k,j,radius);
              return i1;
    public static void main(String[] args) {
    //TestCase 1
    try {
    image i = new image();
    i.rows = 5;
    i.columns = 3;
    i.data = new int[][]{{6, 12, 18}, {5, 11, 17}, {4, 10, 16}, {3, 9, 15}, {2, 8, 14}};
    BlurImage obj = new BlurImage();
    image res = obj.blur_image(i, 2);
    System.out.println("TestCase 1");
    if (res != null) {
    for (int k = 0; k < i.rows; k++) {
    System.out.println();
    for (int j = 0; j < i.columns; j++) {
    System.out.print(res.data[k][j] + ",");
    } else
    System.out.println("NULL");
    catch (Exception e) {
                   e.printStackTrace();
    //TestCase 2
    try {
    image i = new image();
    i.rows = 3;
    i.columns = 5;
    i.data = new int[][]{{0x5a0060, 0x6a0050, 0x6a0050, 0x6a0050, 0x7f0038},
    {0x5a0060, 0x6a0050, 0x6a0050, 0x6a0050, 0x7f0038},
    {0x5a0060, 0x6a0050, 0x6a0050, 0x6a0050, 0x7f0038}};
    BlurImage obj = new BlurImage();
    image res = obj.blur_image(i, 1);
    System.out.println("\nTestCase 2");
    if (res != null) {
    for (int k = 0; k < i.rows; k++) {
    System.out.println();
    for (int j = 0; j < i.columns; j++) {
    System.out.print(Integer.toHexString(res.data[k][j])+ ",");
    } else
    System.out.println("NULL");
    catch (Exception e) {
    e.printStackTrace();
    It should give the output as:------
    test case 1:-
    [ 11, 11, 11 ]
    [ 10, 10, 10 ]
    output.data = [ 10, 10, 10 ]
    [ 9,    9,   9  ]
    [ 9,    9,   9  ]
    test case 2:-
    [ 0x620058, 0x640055, 0x6a0050, 0x710048, 0x740044 ]
    output.data = [ 0x620058, 0x640055, 0x6a0050, 0x710048, 0x740044 ]
    [ 0x620058, 0x640055, 0x6a0050, 0x710048, 0x740044 ]

    public class Test
         public static void main(String args[])
              throws Exception
              System.out.println("[ 10, 10, 10 ]");
    }I'll let you customize the above code for test case 2.
    There is not a single comment in the code. We have no idea what the code is supposed to do. We have no idea what you think is wrong. Therefore the above solution is the best we can provide.

  • What recordset now called can somebody please correct this code? MIchael Horton

    Private Sub ShowRecord_Click()
    Dim rst As DAO.Recordset
    Set rst = [Forms]![Assets].RecordsetClone
    rst.FindFirst "InvestID=" & List2
    [Forms]![Assets].Bookmark = rst.Bookmark
    DoCmd.Close acForm, "GoToRecordDialog"
    End Sub

    You can cater for Nulls by executing the code conditionally.  Also it's advisable to examine the NoMatch property before synchronizing the bookmarks, e.g.
    Const MESSAGETEXT1 = "No asset selected."
    Const MESSAGETEXT2 = "No matching record found."
    Dim frm as Form
    Set frm = Forms("Assets")
    If Not IsNull(Me.List2) Then
       With frm.RecordsetClone
           .FindFirst "InvestID = " & Me.List2
           If Not .NoMatch Then
               frm.Bookmark = .Bookmark
               DoCmd.Close acForm, Me.Name
           Else
               MsgBox MESSAGETEXT2, vbInformation, "Warning"
           End if
        End With
    Else
        MsgBox MESSAGETEXT1, vbExclamation, "Invalid Operation"
    End If
    This does assume of course that the list box's bound column is that containing the InvestID values.
    PS:  It also assumes that the list box is not a multi-select control.
    Ken Sheridan, Stafford, England

Maybe you are looking for

  • Weird behavior in my code.

    class MyCounter implements Runnable {     public void run( ) {         for ( int i = 0; i <= 100; ++i ) {                 if (  ( i % 10) == 0 ) {                    Thread.yield();                    System.out.println( Thread.currentThread().getNam

  • Can I set up a home page in safari

    How can I set up a home page in Safari on the iPad

  • Accounts not hitting sepearte G/L account

    Hi we are working with account assigned Purchase order ( P) projects where the system is picking the G/L account thru valution class from the OBYC and we are giving the WBS element.In my PO we have different conditions for base price , frieght and ot

  • Electronic bank reconciliation -Rejected  transaction

    hi SAP expert I would like to ensure proper automatic accounting entries of rejected Bank transfer -RTGS, NEFT etc. . However through bank reconciliation i am not able to do so . Furhter bank passes both debit and credit entry with same amount and in

  • Dock Magnification Issues

    Since last week when i installed a new software update (the one that had the DVD update that's causing all the problems, but i'm not sure what else i installed at the same time) my dock won't magnify when i mouse over it (once i click on an item it t