Create table test (test1 varchar (20), test2 varchar (20)
Write a test record to the table.
Now let's start our jsp (first choice for SUN Enterprise applications) and database journey.
TestOracle (large website database platform). jsp (preferred for SUN Enterprise Applications) is as follows:
<% @ Page contentType = "text/html; charset = gb2312" %>
<% @ Page import = "java. SQL. *" %>
<Html>
<Body>
<% Class. forName ("Oracle (large website database platform). jdbc. driver. Oracle (large website database platform) Driver"). newInstance ();
String url = "jdbc: Oracle (large website database platform): thin: @ localhost: 1521: orcl ";
// Orcl is the SID of your database
String user = "scott ";
String password = "tiger ";
Connection conn = DriverManager. getConnection (url, user, password );
Statement stmt = conn. createStatement (ResultSet. TYPE_SCROLL_SENSITIVE, ResultSet. CONCUR_UPDATABLE );
String SQL = "select * from test ";
ResultSet rs1_stmt.exe cuteQuery (SQL );
While (rs. next () {%>
The content of your first field is: <% = rs. getString (1) %>
Your second field content is: <% = rs. getString (2) %>
<% }%>
<% Out. print ("database operation successful! "); %>
<% Rs. close ();
Stmt. close ();
Conn. close ();
%>
</Body>
</Html>