Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # TNSNAMES.ORA Network Configuration File: C:oraclenetworkADMINtnsnames.ora
- # Generated by Oracle configuration tools.
- INST1_HTTP =
- (DESCRIPTION =
- (ADDRESS_LIST =
- (ADDRESS = (PROTOCOL = TCP)(HOST = 10.10.4.123)(PORT = 1521))
- )
- (CONNECT_DATA =
- (SID = medst)
- (SERVER = SHARED)
- (PRESENTATION = http://admin)
- )
- )
- MED =
- (DESCRIPTION =
- (ADDRESS_LIST =
- (ADDRESS = (PROTOCOL = TCP)(HOST = 10.10.4.113)(PORT = 1521))
- )
- (CONNECT_DATA =
- (SID = med)
- )
- )
- db.host = jdbc:mysql://localhost/shop
- db.user = shop
- db.password = 123456
- public class DBConnection {
- public static Connection getConnection() throws SQLException, IOException {
- Properties properties = new Properties();
- try (InputStream in = Files.newInputStream(Paths.get("db.properties"))) {
- properties.load(in);
- }
- String host = properties.getProperty("db.host");
- String user = properties.getProperty("db.user");
- String password = properties.getProperty("db.password");
- return DriverManager.getConnection(host, user, password);
- }
- }
Add Comment
Please, Sign In to add comment