Java Code Examples for org.postgresql.ds.PGSimpleDataSource#getConnection()
The following examples show how to use
org.postgresql.ds.PGSimpleDataSource#getConnection() .
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 |
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 |
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 |
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 |
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 |
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 6
Source File: PostgresqlSuite.java From mybatis-types with MIT License | 5 votes |
public static synchronized void INIT() { PGSimpleDataSource ds = new PGSimpleDataSource(); ds.setUrl(PG_URL); try (final Connection cnx = ds.getConnection(); final Statement st = cnx.createStatement()) { st.execute(TestSuite.getResourceAsString(PG_SQL)); } catch (Exception ex) { throw new RuntimeException(ex); } TestSuite.setupSessionFactoryBuilder(ds); }