diff options
Diffstat (limited to 'org/madore/damlengine/WeblogDatabaseConnection.java')
-rw-r--r-- | org/madore/damlengine/WeblogDatabaseConnection.java | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/org/madore/damlengine/WeblogDatabaseConnection.java b/org/madore/damlengine/WeblogDatabaseConnection.java new file mode 100644 index 0000000..a1dfc1f --- /dev/null +++ b/org/madore/damlengine/WeblogDatabaseConnection.java @@ -0,0 +1,30 @@ +package org.madore.damlengine; + +import java.util.Properties; +import java.sql.Connection; +import java.sql.SQLException; +import org.postgresql.Driver; + +public final class WeblogDatabaseConnection { + + private WeblogDatabaseConnection() { // Forbid instantiation + throw new AssertionError("WeblogDatabaseConnection cannot be instantiated"); + } + + public static Connection conn; + + public static Connection getConnection() + throws SQLException { + if ( conn == null ) { + final String dbUrl = "jdbc:postgresql://localhost/weblog"; + final Properties dbProps = new Properties(); + dbProps.setProperty("user", "david"); + dbProps.setProperty("password", "IHATETHISWHYCANTIUSEUNIXDOMAINSOCKETS"); + dbProps.setProperty("ssl", "true"); + dbProps.setProperty("sslfactory", "org.postgresql.ssl.NonValidatingFactory"); + conn = (new Driver()).connect(dbUrl, dbProps); + } + return conn; + } + +} |