Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_jsp thread: current RECORD values


Message #1 by "James McIntosh" <wakko_j@h...> on Sat, 21 Jul 2001 11:24:33
I was wondering how you can get the value of a field in a database when you
are adding a new record and are not posting that value yourself (eg an auto
incrementing value)

Here is my code. I need the value of the AUTO_ID field from the DB to be
outputted at XXXXXX

Class.forName("org.gjt.mm.mysql.Driver");
Connection myConn 
DriverManager.getConnection("jdbc:mysql:///mydatabase?user=aaa&password=bbb");
Statement stmt = myConn.createStatement();
int rowsAffected = 0;
try {
	rowsAffected = stmt.executeUpdate("INSERT INTO customer 
(FAMILY,GIVEN,ADDRESS) VALUES ('" + request.getParameter("FAMILY") + "','" + 
request.getParameter("GIVEN") + "','" + request.getParameter("ADDRESS") "') 
");
	if (request.getParameter("where") != null) {
		String where = request.getParameter("where");
		if (where.equalsIgnoreCase("invoice")) {
			request.sendRedirect("invoice.jsp?id=" + XXXXXX);
		}
	}
} catch (SQLException se) {}

Thanks HEAPS for any assistance you can give me
James McIntosh
james@w...


  Return to Index