how to auto generate number in jsp with the database connection mysql for employee number?
<%@page import="java.sql.*"%> <% try { Class.forName("com.mysql.jdbc.Driver").newInstance(); Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root"); Statement st = conn.createStatement(); ResultSet rs=st.executeQuery("SELECT id FROM user"); int id=0; if(rs.last()){ id=rs.getInt("id")+1; } st.executeUpdate("insert into user(id,name,address) values("+id+",'rose','delhi')"); out.println("Data is inserted successfully"); } catch(Exception e){} %>
Ads