Results 1 to 2 of 2

Thread: mysql database error

  1. #1
    Junior Member
    Join Date
    Feb 2004
    Posts
    21

    Unhappy mysql database error


    for your information, i'm using jsp to create my web page. i am inserting sequence number into the database. When first data in insert into database it will show number 1 in the database. when second data in insert in database, it will show number 2 in the database. the data are inserted when user click submit button from the web page.
    i am creating a page name main.jsp. when the user select option from the list bar, it will link to new page. the option value in the list bar are 'sentul view' and 'cityview'. if the user choose 'cityview', it will link to new page that allows user to key in their information. the problem is sequence number was enter wrongly into database. when the first user click submit after selected "city view', sequence in 'cityview' database will increase. then when the other user register 'sentul view', the database sequence will start from number 2 in 'sentul view' database. how to avoid the problem...
    i enclosed some part of the code:

    <%
    String sql_selectMax = "SELECT max(smb_regr_seq_no) as maxNo "+
    "FROM smbyer ";
    Statement stmt_selectMax = conn.createStatement();
    ResultSet rset_selectMax = stmt_selectMax.executeQuery(sql_selectMax);
    while(rset_selectMax.next()){
    reqNo = rset_selectMax.getInt("maxNo");
    out.print (reqNo);
    }
    reqNo = reqNo + 1;
    %>

  2. #2
    SG Enthusiast
    Join Date
    Jan 2001
    Location
    DC
    Posts
    4,717
    I use the "auto_increment" in column definition and never have this problem. You never update that value and it will automatically increment. This only works well for atomic tables - if you are putting this all in one table then that's your problem.

    The code you posted doesn't help - why not post your schema. I think that's where your problem is. Are these separate databases, separate tables, or all records in the same table?

    A view is just a way of looking at the data - it sounds like your two views are pointed at the same table.
    anything is possible - nothing is free


    Quote Originally Posted by Blisster
    It *would* be brokeback bay if I in fact went and hung out with Skye and co (did I mention he is teh hotness?)

Similar Threads

  1. Router Not Loading Webpage Properly
    By ChuckDees in forum Networking Forum
    Replies: 6
    Last Post: 04-08-04, 07:58 PM
  2. colorgenics!
    By onetrueday in forum General Discussion Board
    Replies: 22
    Last Post: 01-30-02, 11:58 PM
  3. Error messages
    By Humboldt in forum General Discussion Board
    Replies: 1
    Last Post: 11-11-01, 05:15 PM
  4. Replies: 6
    Last Post: 03-29-01, 06:29 PM
  5. AT&T RoadRunner Atlanta Congestion Problems.
    By megabit in forum General Broadband Forum
    Replies: 27
    Last Post: 03-21-01, 09:56 AM

Bookmarks

Posting Permissions

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