⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 selectexample.java

📁 Java示例100
💻 JAVA
字号:
/* * This sample shows how to retrieve and list all the names * (FIRST_NAME, LAST_NAME) from the EMPLOYEES table * * note: jdk1.2 is recommanded. jdk1.1 will also work */// You need to import the java.sql package to use JDBCimport java.sql.*;class SelectExample{  public static void main (String args [])       throws SQLException  {    // Load the Oracle JDBC driver    DriverManager.registerDriver(new oracle.jdbc.OracleDriver());    String url = "jdbc:oracle:oci8:@";    try {      String url1 = System.getProperty("JDBC_URL");      if (url1 != null)        url = url1;    } catch (Exception e) {      // If there is any security exception, ignore it      // and use the default    }    // Connect to the database    Connection conn =       DriverManager.getConnection (url, "hr", "hr");    // Create a Statement    Statement stmt = conn.createStatement ();    // Select first_name and last_name column from the employees table    ResultSet rset = stmt.executeQuery ("select FIRST_NAME, "                                        + "LAST_NAME from EMPLOYEES");    // Iterate through the result and print the employee names    while (rset.next ())      System.out.println (rset.getString (1) + " " + rset.getString (2));    // Close the RseultSet    rset.close();    // Close the Statement    stmt.close();    // Close the connection    conn.close();     }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -