如何将数据库查询到的结果输出在页面上'
2017-09-09
展开全部
public class OraDriver{
public static void main(String args[]) throws Exception{
//利用Oracle驱动进行连接
Class.forName("oracle.jdbc.driver.OracleDriver");//载入驱动
String url = "jdbc:oracle:thin:@localhost:1521:SCHOOL";
Connection conn = DriverManager.getConnection(url,"scott","tiger");
Statement stat = conn.createStatement();
ResultSet rs = stat.executeQuery("SELECT 姓名 FROM 学籍");
while(rs.next()){
System.out.println(rs.getString("姓名"));
}
}
}
public static void main(String args[]) throws Exception{
//利用Oracle驱动进行连接
Class.forName("oracle.jdbc.driver.OracleDriver");//载入驱动
String url = "jdbc:oracle:thin:@localhost:1521:SCHOOL";
Connection conn = DriverManager.getConnection(url,"scott","tiger");
Statement stat = conn.createStatement();
ResultSet rs = stat.executeQuery("SELECT 姓名 FROM 学籍");
while(rs.next()){
System.out.println(rs.getString("姓名"));
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询