1: package testbed.unsafe; 2: import java.sql.*; 3: import java.util.Properties; 4: import java.io.*; 5: public class U256 { 6: public void f(String url, String name) throws IOException { 7: Connection con = null; 8: try { 9: Properties props = new Properties(); 10: FileInputStream in = new FileInputStream("External.properties"); 11: byte[] pass = new byte[8]; 12: // 외부 파일로부터 password를 읽는다. 13: in.read(pass); 14: // password가 DB connection의 인자변수로 그대로 사용이 된다. 15: con = DriverManager.getConnection(url, name, new String(pass)); 16: con.close(); 17: } catch (SQLException e) { 18: System.err.println("SQLException Occured "); 19: } finally { 20: try { 21: if (con != null) 22: con.close(); 23: } catch (SQLException e) { 24: System.err.println("SQLException Occured "); 25: } 26: } 27: } 28: }