/* * JDBCOracleDemo.java * Demonstrate how to use JDBC driver with Oracle 8i database * * Created by Mobilefish.com (http://www.mobilefish.com) * * File: JDBCOracleDemo.java * Needs: JDBC driver oracle12.zip. * Resources: - * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later * version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with * this program; if not, write to the Free Software Foundation, Inc., 59 Temple * Place, Suite 330, Boston, MA 02111-1307 USA * * If you have any questions, please contact contact@mobilefish.com */ import java.sql.*; public class JDBCOracleDemo { public static void main (String args []) throws SQLException{ // Load the Orcale driver DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver()); // Make a conection to the Oracle database // jdbc:oracle:thin:@host:port:SID,userid,password Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl", "root", "mysecret"); Statement stmt = conn.createStatement(); ResultSet rset = stmt.executeQuery("select * from user"); while (rset.next()){ System.out.println (rset.getString(2)); // Print col 2 } stmt.close(); } }