First establish a data source name: TEST database is also: Test one of the tables: Test
<% // loaded String Url = new string (); URL = "JDBC: ODBC: TEST"; // The Teach here is the name of the data source. Class.Forname ("Sun.jdbc.odbc.jdbCodbcDriver"); // Class.Forname Load Driver Connection Con = DriverManager.getConnection (URL); Create a connection with DBMS with DBMS with DBMS. .createstatement (); // Connect database string sql = "select * from test"; ResultSet RS = stmt.executeQuery (SQL); while (rs.next ()) {%> Your first field content is: < % = rs.getstring (1)%>
Your second field content is: <% = rs.getstring (2)%>
<%}%> <% out.print ("database operation Success, congratulations ");%> <% rs.close (); stmt.close () ;con.close ();%>