You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@mahout.apache.org by Emil Kjer <em...@kjer.info> on 2012/10/25 05:42:38 UTC

Re: Mahout and a Postgresql datasource

Assuming your jdbc driver is installed correctly you can for example use a
PGSimpleDataSource or the pooling version PGPoolingDataSource (
http://jdbc.postgresql.org/documentation/80/ds-ds.html
<http://jdbc.postgresql.org/documentation/80/ds-ds.html>  )

import org.postgresql.ds.PGSimpleDataSource;
PGSimpleDataSource dataSource = new PGSimpleDataSource();
dataSource.setServerName("127.0.0.1");
dataSource.setUser("emil");
dataSource.setPassword("verysecretpassword");
dataSource.setDatabaseName("mydb");
dataSource.setPortNumber(5432);

Connection conn = null;
try {
    System.out.println("GOOD STUFF");
    conn = dataSource.getConnection();
    //Test connection
    System.out.println(conn.getClientInfo());
    System.out.println("YAY we are in!");
} catch (SQLException e) {
    System.out.println(e.getMessage());
} finally {
    if (conn != null) {
        try {
            conn.close();
        } catch (SQLException e) {
            System.out.println(e.getMessage());
        }
    }
}



--
View this message in context: http://lucene.472066.n3.nabble.com/Mahout-and-a-Postgresql-datasource-tp3992426p4015755.html
Sent from the Mahout User List mailing list archive at Nabble.com.