Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JSP-Servlet how to auto generate number in jsp with the database connection mysql for employee number?
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


shweta patil
how to auto generate number in jsp with the database connection mysql for employee number?
1 Answer(s)      2 years and 8 months ago
Posted in : JSP-Servlet


how to auto generate number in jsp with the database connection mysql for employee number?


Advertisement
View Answers

March 21, 2012 at 12:04 PM


<%@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){}
%>


Related Tutorials/Questions & Answers:
Advertisements
Advertisements
 

 

 

DMCA.com