1<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "2Pageencoding= "UTF-8"Import= "Java.sql.*"%>3<! DOCTYPE html>456<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">7<title> Receive form data </title>89<body>Ten<p>Get the text box submission information: One<% A - -String jdbc_driver = "Com.mysql.jdbc.Driver"; theString Db_url = "Jdbc:mysql://localhost:3306/first"; - - -String USER = "root"; +String PASS = "******"; - +Connection conn =NULL; AStatement stmt =NULL; at Try{ - //Load Driver -Class.forName ("Com.mysql.jdbc.Driver"); - -SYSTEM.OUT.PRINTLN ("Connecting to Database ..."); - //Create Connection inconn =drivermanager.getconnection (db_url,user,pass); - toSYSTEM.OUT.PRINTLN ("Creating statement ..."); + //Create Query -stmt =conn.createstatement (); the String SQL; *sql = "SELECT * FROM First.author"; $ResultSet rs =stmt.executequery (SQL);Panax Notoginseng //Get Data - while(Rs.next ()) { the intid = rs.getint ("id"); + intAge = Rs.getint ("Age"); AString author = rs.getstring ("Author"); theString represent = rs.getstring ("Represent"); + -System.out.print ("ID:" +ID); $System.out.print (", Age:" +Age ); $System.out.print (", Author:" +author); -System.out.println (", Represent:" +represent); - } the rs.close (); - stmt.close ();Wuyi conn.close (); the}Catch(SQLException se) { - se.printstacktrace (); Wu}Catch(Exception e) { - e.printstacktrace (); About}finally{ $ Try{ - if(stmt!=NULL) - stmt.close (); -}Catch(SQLException se2) { A } + Try{ the if(conn!=NULL) - conn.close (); $}Catch(SQLException se) { the se.printstacktrace (); the } the } theSystem.out.println ("goodbye!"); - in%> the</body> theExample of a JDBC connection under Tomcat