Java examples for java.sql:Oracle
get Connection to Oracle Database
//package com.java2s; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; public class Main { public static void main(String[] argv) throws Exception { System.out.println(getConnection()); }/*from w w w.j a va 2s . co m*/ public static Connection getConnection() throws SQLException { try { Class.forName("oracle.jdbc.driver.OracleDriver"); } catch (ClassNotFoundException e) { e.printStackTrace(); } Connection conn = DriverManager.getConnection( "jdbc:oracle:thin:@localhost:1521:orcl", "userName", "pass"); return conn; } }