You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@mahout.apache.org by wielliam <wi...@gmail.com> on 2012/07/02 04:34:58 UTC

Mahout and a Postgresql datasource

what is the equivalent of this line for Postgresql?

MysqlDataSource dataSource = new MysqlDataSource ();

Im also wondering which class to import that lets me instantiate the
datasource object. I have added the drivers and mahout-integration to my
pom.xml file but I still cant instantiate that particular object for either
type of database


<build>
    <plugins>
      <plugin>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>maven-jetty-plugin</artifactId>
        <version>6.1.10</version>
      </plugin>
    </plugins>
  </build>
  <groupId>com.unresyst</groupId>
  <artifactId>mahoutrec</artifactId>
  <version>1.0-SNAPSHOT</version>
  <name>mahoutrec</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>org.apache.mahout</groupId>
      <artifactId>mahout-integration</artifactId>
      <version>0.7</version>
    </dependency>
    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <version>5.1.20</version>
    </dependency>
    <dependency>
      <groupId>postgresql</groupId>
      <artifactId>postgresql</artifactId>
      <version>9.1-901.jdbc4</version>
    </dependency>

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

Re: Mahout and a Postgresql datasource

Posted by Sean Owen <sr...@gmail.com>.
I don't know actually, but this is a PostgreSQL question. Look for
docs on its Java driver. Same about what provides the driver, you'd
have to check PostgreSQL.

Connector/J definitely has this class for MySQL, you must be doing
something wrong if you can't use it with this pom.

On Mon, Jul 2, 2012 at 5:34 AM, wielliam <wi...@gmail.com> wrote:
> what is the equivalent of this line for Postgresql?
>
> MysqlDataSource dataSource = new MysqlDataSource ();
>
> Im also wondering which class to import that lets me instantiate the
> datasource object. I have added the drivers and mahout-integration to my
> pom.xml file but I still cant instantiate that particular object for either
> type of database
>
>

Re: Mahout and a Postgresql datasource

Posted by Emil Kjer <em...@kjer.info>.
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.