Home  >  Article  >  Database  >  JSP 连接Oracle数据库例子

JSP 连接Oracle数据库例子

WBOY
WBOYOriginal
2016-06-07 16:59:271243browse

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

Statement:
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