Results 1 to 4 of 4

Thread: help!!!

  1. #1
    shuvra_pan is offline Member
    Join Date
    Jun 2008
    Posts
    10
    Rep Power
    0

    Default help!!!

    <%@page import="java.sql.*"%>
    <%@page import="java.io.*"%>
    <%@include file="dbconnection.jsp"%>
    {
    String loc=request.getParameter("Location");
    String qul=request.getParameter("Qualification");
    String pro=request.getParameter("Programming");
    String db=request.getParameter("Database");
    String plat=request.getParameter("Platform");
    Statement stmt=con.createStatement();
    ResultSet rs=stmt.executeQuery("select max(loc_id) from group1_location_master order by loc_id");
    int i=0;
    while(rs.next())
    {
    i=rs.getInt(1);
    i++;
    stmt.executeUpdate("insert into group1_location_master(loc_id,loc_name)values('"+i +"','"+loc+"')");
    System.out.println(loc);
    }
    ResultSet rs1=stmt.executeQuery("select max(quali_id) from group1_qualification_master");
    {
    stmt.executeUpdate("insert into group1_qualification_master(quali_id,degree)values ("+i+",'"+qul+"')");
    System.out.println(qul);
    }
    ResultSet rs2=stmt.executeQuery("select max(programming_id) from group1_program_skill_master");
    {
    stmt.executeUpdate("insert into group1_program_skill_master(programming_id,program ming_skill)values("+i+",'"+pro+"')");
    System.out.println(pro);
    }
    ResultSet rs3=stmt.executeQuery("select max(database_id) from group1_database_skill_master");
    {
    stmt.executeUpdate("insert into group1_database_skill_master(database_id,database_ skill)values('"+i+"','"+db+"')");
    System.out.println(db);
    }
    ResultSet rs4=stmt.executeQuery("select max(platform_id) from group1_platform_skill_master");
    {
    stmt.executeUpdate("insert into group1_platform_skill_master(platform_id,platform_ skill)values('"+i+"','"+plat+"')");
    System.out.println(plat);
    }
    %>


    guyz when i will enter a location the loc_id will automatically update with a value..itz happening but the prob is itz not showing in order by....

    itz showing like this........... if there is any correction needed in the above code plz make it......

    LOC_ID LOC_NAME
    ---------- -------------
    3 delhi
    4 mumbai
    1 kolkata
    2 chennai

  2. #2
    Md Saim is offline Member
    Join Date
    Sep 2008
    Location
    Kolkata, India
    Posts
    20
    Rep Power
    0

    Default

    Add the open screiptlet <%


    <%@page import="java.sql.*"%>
    <%@page import="java.io.*"%>
    <%@include file="dbconnection.jsp"%>
    <%
    {
    String loc=request.getParameter("Location");
    String qul=request.getParameter("Qualification");
    String pro=request.getParameter("Programming");
    String db=request.getParameter("Database");
    .....

    use order by LOC_ID in sql query.

  3. #3
    shuvra_pan is offline Member
    Join Date
    Jun 2008
    Posts
    10
    Rep Power
    0

    Default

    In sql the order by query works fine.But its not my requirement i want when i will insert the location that time location id genarate sequencially in the database...

  4. #4
    serjant's Avatar
    serjant is offline Senior Member
    Join Date
    Jun 2008
    Location
    Ukraine,Zaporozhye
    Posts
    487
    Rep Power
    6

    Default

    If you want to sort the records in a descending order
    Java Code:
    ResultSet rs=stmt.executeQuery("SELECT max(loc_id) FROM group1_location_master ORDER BY loc_id DESC");
    And vice versa

    Java Code:
    ResultSet rs=stmt.executeQuery("SELECT max(loc_id) FROM group1_location_master ORDER BY loc_id ASC");

Posting Permissions

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