Results 1 to 4 of 4
  1. #1
    waqashaider is offline Member
    Join Date
    May 2012
    Posts
    4
    Rep Power
    0

    Default Array Index out of bound -------- whats the problem with my code

    import java.sql.*;

    public class NewEx
    {

    public static void main (String args[])
    {
    try
    {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); //load driver
    String url = "jdbc:odbc:personDSN";// define connection
    Connection con = DriverManager.getConnection(url); //establish connection
    Statement st = con.createStatement();//create statement
    String paddVar = args[0];
    String pnameVar = args[1];
    String sql = "UPDATE Person SET paddress ="Defence"WHERE pname = "Ali"";
    int num = st.executeUpdate(sql);
    System.out.println(num+"records updated");

    con.close();
    }
    catch(Exception sqlEx)
    {
    System.out.println(sqlEx);
    }

    }}

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,044
    Blog Entries
    7
    Rep Power
    23

    Default Re: Array Index out of bound -------- whats the problem with my code

    The only array you're using in your code is the 'args' array; you probably didn't supply are least two command line arguments.

    kind regards,

    Jos
    The only person who got everything done by Friday was Robinson Crusoe.

  3. #3
    waqashaider is offline Member
    Join Date
    May 2012
    Posts
    4
    Rep Power
    0

    Default Re: Array Index out of bound -------- whats the problem with my code

    Well can you guide me how i can do that
    ???

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,044
    Blog Entries
    7
    Rep Power
    23

    Default Re: Array Index out of bound -------- whats the problem with my code

    Supply at least two arguments to your program:

    Java Code:
    java NewEx foo bar
    Your program takes foo and bar as its two arguments.

    kind regards,

    Jos
    The only person who got everything done by Friday was Robinson Crusoe.

Similar Threads

  1. array index out of bound error
    By anya in forum New To Java
    Replies: 8
    Last Post: 04-27-2012, 09:24 AM
  2. Array Index Out of Bound
    By ankiit in forum New To Java
    Replies: 9
    Last Post: 01-04-2012, 07:03 AM
  3. Array index out of bound exception error
    By rahulkrishnanr in forum Threads and Synchronization
    Replies: 7
    Last Post: 10-12-2010, 05:57 PM
  4. Array index Out of bound Exception
    By nitin_daviet88 in forum New To Java
    Replies: 9
    Last Post: 07-28-2010, 05:32 AM
  5. Array Index Out of bound exception
    By abhijit in forum Networking
    Replies: 7
    Last Post: 09-25-2009, 07:25 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •