1.数据库的建立
2.创建项目文件
<%@ page language="java"contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ pageimport="java.sql.*"%>
<%@ pageimport="java.io.*"%>
<%@ pageimport="java.util.*"%>
<!doctypehtml>
<html>
<head>
</head>
<body>
<tableborder="1">
<tr><td>姓名</td><td>薪资</td></tr>
<%
Connection conn=null;
Statement sql=null;
ResultSet rs=null;
String url="jdbc:Oracle:thin:@localhost:1521:orcl";
//test为你的数据库的SID
String user="system";
String passWord="admin";
String sql1="select* from table1";
Class.forName("oracle.jdbc.driver.OracleDriver");
conn= DriverManager.getConnection(url,user,password);
sql=conn.createStatement();
rs=sql.executeQuery(sql1);
while(rs.next()) {%>
<tr>
<td><%=rs.getString(1)%></td>
<td><%=rs.getString(2)%></td>
</tr>
<%}%>
</table>
</body>
</html>3. 载入oracle jar包
新闻热点
疑难解答