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 online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,663
    Blog Entries
    7
    Rep Power
    21

    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
    cenosillicaphobia: the fear for an empty beer glass

  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 online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,663
    Blog Entries
    7
    Rep Power
    21

    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
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. array index out of bound error
    By anya in forum New To Java
    Replies: 8
    Last Post: 04-27-2012, 10: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, 06:57 PM
  4. Array index Out of bound Exception
    By nitin_daviet88 in forum New To Java
    Replies: 9
    Last Post: 07-28-2010, 06:32 AM
  5. Array Index Out of bound exception
    By abhijit in forum Networking
    Replies: 7
    Last Post: 09-25-2009, 08: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
  •