|
5 | 5 |
|
6 | 6 |
|
7 | 7 | import java.io.FileInputStream;
|
8 |
| -import java.io.IOException; |
9 | 8 | import java.sql.Connection;
|
10 | 9 | import java.sql.DatabaseMetaData;
|
11 | 10 | import java.sql.DriverManager;
|
12 |
| -import java.sql.SQLException; |
13 | 11 | import java.util.Properties;
|
14 | 12 |
|
15 | 13 |
|
|
18 | 16 |
|
19 | 17 | public class ConnectionTest {
|
20 | 18 |
|
21 |
| - public String makeConnection() throws IOException, ClassNotFoundException, SQLException { |
| 19 | + public static void main(String[] args) throws Exception { |
| 20 | + |
22 | 21 | Properties props = new Properties();
|
23 |
| - FileInputStream fis = new FileInputStream("src/com/mikusher/dwr/connection/db.properties"); |
24 |
| - props.load(fis); |
25 |
| - fis.close(); |
26 |
| - String connectionShow; |
| 22 | + FileInputStream fis = new FileInputStream("src/cv/bockdamm/tst/db.properties"); |
| 23 | + props.load(fis); |
| 24 | + fis.close(); |
27 | 25 |
|
28 |
| - String postgresconnection = props.getProperty("postgres.url") + props.getProperty("postgres.dbName"); |
29 |
| - String postgresusr = props.getProperty("postgres.user"); |
30 |
| - String postgrespsw = props.getProperty("postgres.passwd"); |
| 26 | + String postgresconnection = props.getProperty("postgres.url") + props.getProperty("postgres.dbName"); |
| 27 | + String postgresusr = props.getProperty("postgres.user"); |
| 28 | + String postgrespsw = props.getProperty("postgres.passwd"); |
31 | 29 |
|
32 |
| - Class.forName(props.getProperty("postgres.driver")); |
| 30 | + Class.forName(props.getProperty("postgres.driver")); |
33 | 31 |
|
34 | 32 | try (Connection dbpsql = DriverManager.getConnection(postgresconnection, postgresusr, postgrespsw)) {
|
35 | 33 | DatabaseMetaData dbpsqlmd = dbpsql.getMetaData();
|
36 | 34 |
|
37 |
| - connectionShow = "Connection to " + dbpsqlmd.getDatabaseProductName() + " " |
38 |
| - + dbpsqlmd.getDatabaseProductVersion() + " successful.\n"; |
| 35 | + System.out.println("Connection to " + dbpsqlmd.getDatabaseProductName() + " " |
| 36 | + + dbpsqlmd.getDatabaseProductVersion() + " successful.\n"); |
39 | 37 | }
|
40 |
| - |
41 |
| - return connectionShow; |
42 |
| - |
43 | 38 | }
|
44 | 39 | }
|
0 commit comments