Home > Database > Mysql Tutorial > body text

JSP 连接Oracle数据库例子

WBOY
Release: 2016-06-07 16:59:27
Original
1240 people have browsed it

lt;% Class.forName(quot;oracle.jdbc.driver.OracleDriverquot;); //.newInstance(); String url=quot;jdbc:oracle:thi

  Class.forName("Oracle.jdbc.driver.OracleDriver");   //.newInstance();
  String url="jdbc:oracle:thin:@127.0.0.1:1521:yyyy";
   //mydb为数据库的SID,,10.0.1.1 为 数据库服务器 IP
  String user="sys as sysdba";
  String password="yyyy";
  Connection conn= DriverManager.getConnection(url, user, password);
  Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
  String sql="select * from test";  //test 是表名,要先建立这个表,再送几条记录
  ResultSet rs=stmt.executeQuery(sql);
  while(rs.next())
  {
%>
    第一个字段内容为:
    第二个字段内容为:

  }
  out.print("数据库操作成功,恭喜。");

  rs.close();
  stmt.close();
  conn.close();
%>

linux

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!