Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Error in updating database

  1. #1
    Junior Member
    Join Date
    Aug 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Error in updating database

    Statement stm=con.createStatement();
    PreparedStatement ps=conn.prepareStatement("insert into regis values(?,?,?,?,?,?,?,?,?,?)");
    ps.setString(2, username);
    ps.setString(3, password);
    ps.setString(4, confirmpassword);
    ps.setString(5, firstname);
    ps.setString(6, lastname);
    ps.setInt(7, age);
    ps.setDate(8, new java.sql.Date(date.getTime()));
    ps.setString(9, teamname);
    ps.setString(10, designation);

    my index 1 is declared as int auto increment not null but while i am upting from servlet it didnt update properly even still it show emptyset .
    what i have to do?


  2. #2
    Junior Member
    Join Date
    Aug 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Error in updating database

    i found that error. we have to insert this one unless the database will not auto increment
    ps.setObject(1,null);

  3. #3
    Super Moderator Sean4u's Avatar
    Join Date
    Jul 2011
    Location
    Tavistock, UK
    Posts
    637
    Thanks
    5
    Thanked 103 Times in 93 Posts

    Default Re: Error in updating database

    If you don't want to to set all the values of a newly-inserted row, use this form of the INSERT statement:
    INSERT INTO regis (columnb, columnc, columnd) VALUES (?, ?, ?)
    to set only those columns of the new row that aren't generated by triggers/auto-increments etc.

Similar Threads

  1. Need Help on Updating a GUI Java
    By coyboss in forum Object Oriented Programming
    Replies: 9
    Last Post: March 6th, 2011, 09:00 PM
  2. Updating timer
    By The_Mexican in forum What's Wrong With My Code?
    Replies: 10
    Last Post: January 26th, 2011, 06:02 AM
  3. Replies: 6
    Last Post: August 18th, 2010, 05:41 PM
  4. Replies: 1
    Last Post: January 15th, 2010, 12:32 AM
  5. updating database
    By gurpreetm13 in forum JDBC & Databases
    Replies: 3
    Last Post: October 9th, 2009, 11:43 AM