熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Oracle >> 正文

一個JAVA連接ORACLE的例子

2022-06-13   來源: Oracle 

  例子
  
  package netabcadmin;
  
  import javaio*;
  import javasql*;
  import javautil*;
  
  public class ConnectionBean
  {
  private static Connection conn = null;
  
  public static Connection getConnection()
  {
  if (conn == null)
  {
  try
  {
  DriverManagerregisterDriver(new oraclejdbcdriverOracleDriver());
  conn = DriverManagergetConnection(jdbc:oracle:thin:@+hostname+:+port+:+dbSIDusernamepassword);
  } catch(SQLException e)
  {
  eprintStackTrace();
  }
  // if(conn == null)
  // Systemoutprintln(database connection error);
  }
  return conn;
  }
  }
  

From:http://tw.wingwit.com/Article/program/Oracle/201311/18550.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.