db utility in java

Solutions on MaxInterview for db utility in java by the best coders in the world

showing results for - "db utility in java"
Jason
26 Feb 2017
1public class DB_Utility {
2    // adding static field so we can access in all static methods
3    private static Connection conn;
4    private static Statement stmnt;
5    private static ResultSet rs ;
6
7
8    /*
9     * a static method to create connection
10     * with valid url and username password
11     * */
12    public static void createConnection() {
13
14        String connectionStr = ConfigurationReader.getProperty("database.url");
15        String username = ConfigurationReader.getProperty("database.username");
16        String password = ConfigurationReader.getProperty("database.password");
17
18     try {
19        conn = DriverManager.getConnection(connectionStr, username, password);
20        System.out.println("CONNECTION SUCCESSFUL");
21     } catch (SQLException e) {
22        System.out.println("CONNECTION HAS FAILED!");
23        e.printStackTrace();
24        }
25//         createConnection(connectionStr,username,password);
26
27    }
similar questions
queries leading to this page
db utility in java