Java tutorial
//package com.java2s; import java.io.*; import java.sql.*; import java.util.*; public class Main { private static String driver; private static String url; private static String dbUser; private static String dbPwd; public static Connection getConnection() { Connection conn = null; getParam("oracle.properties"); try { Class.forName(driver); conn = DriverManager.getConnection(url, dbUser, dbPwd); } catch (Exception e) { e.printStackTrace(); } return conn; } public static void getParam(String filename) { Properties props = new Properties(); File file = new File(filename); try { props.load(new FileInputStream(file)); // String value = props.getProperty(key); driver = props.getProperty("driver"); url = props.getProperty("url"); dbUser = props.getProperty("dbUser"); dbPwd = props.getProperty("dbPwd"); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }