Java Code Examples for org.postgresql.ds.PGSimpleDataSource#setLoginTimeout()

The following examples show how to use org.postgresql.ds.PGSimpleDataSource#setLoginTimeout() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Connect.java    From Learn-Java-12-Programming with MIT License 5 votes vote down vote up
private static void dataSourceSimple() {
    PGSimpleDataSource source = new PGSimpleDataSource();
    source.setServerName("localhost");
    source.setDatabaseName("learnjava");
    source.setUser("student");
    //source.setPassword("password");
    source.setLoginTimeout(10);
    try {
        Connection conn = source.getConnection();
    } catch (SQLException ex) {
        ex.printStackTrace();
    }
}
 
Example 2
Source File: Chapter06Database01.java    From Java-11-Cookbook-Second-Edition with MIT License 5 votes vote down vote up
private static Connection getDbConnection2(){
    PGSimpleDataSource source = new PGSimpleDataSource();
    source.setServerName("localhost");
    source.setDatabaseName("cookbook");
    source.setLoginTimeout(10);
    try {
        return source.getConnection();
    }
    catch(Exception ex) {
        ex.printStackTrace();
        return null;
    }
}
 
Example 3
Source File: Chapter06Database02.java    From Java-11-Cookbook-Second-Edition with MIT License 5 votes vote down vote up
private static Connection getDbConnection2(){
    PGSimpleDataSource source = new PGSimpleDataSource();
    source.setServerName("localhost");
    source.setDatabaseName("cookbook");
    source.setLoginTimeout(10);
    try {
        return source.getConnection();
    }
    catch(Exception ex) {
        ex.printStackTrace();
        return null;
    }
}
 
Example 4
Source File: Chapter06Database01.java    From Java-9-Cookbook with MIT License 5 votes vote down vote up
private static Connection getDbConnection2(){
    PGSimpleDataSource source = new PGSimpleDataSource();
    source.setServerName("localhost");
    source.setDatabaseName("cookbook");
    source.setLoginTimeout(10);
    try {
        return source.getConnection();
    }
    catch(Exception ex) {
        ex.printStackTrace();
        return null;
    }
}
 
Example 5
Source File: Chapter06Database02.java    From Java-9-Cookbook with MIT License 5 votes vote down vote up
private static Connection getDbConnection2(){
    PGSimpleDataSource source = new PGSimpleDataSource();
    source.setServerName("localhost");
    source.setDatabaseName("cookbook");
    source.setLoginTimeout(10);
    try {
        return source.getConnection();
    }
    catch(Exception ex) {
        ex.printStackTrace();
        return null;
    }
}