blob: 541be6617a71541a4b7832e0d2711bcddeb97317 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
/*
* Copyright (c) 2011-2013, 2016 Eike Stepper (Berlin, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Eike Stepper - initial API and implementation
*/
package org.eclipse.emf.cdo.tests.db;
import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
import org.eclipse.net4j.db.IDBAdapter;
import org.eclipse.net4j.db.postgresql.PostgreSQLAdapter;
import org.postgresql.ds.PGSimpleDataSource;
import javax.sql.DataSource;
import java.sql.SQLException;
/**
* @author Victor Roldan Betancort
*/
public class PostgresqlConfig extends AbstractSetupDBConfig
{
public static final String DB_ADAPTER_NAME = "Postgresql";
public static final String HOST = "localhost";
public static final String USER = "postgres";
public static final String PASS = "postgres";
public static final String SETUP_DATABASE_NAME = "postgres";
private static final long serialVersionUID = 1L;
public PostgresqlConfig(boolean supportingAudits, boolean supportingBranches, IDGenerationLocation idGenerationLocation)
{
super(DB_ADAPTER_NAME, supportingAudits, supportingBranches, false, false, false, idGenerationLocation);
}
@Override
protected String getDBAdapterName()
{
return DB_ADAPTER_NAME;
}
@Override
protected IDBAdapter createDBAdapter()
{
return new PostgreSQLAdapter();
}
@Override
protected DataSource createDataSourceForDB(String dbName) throws SQLException
{
PGSimpleDataSource dataSource = new PGSimpleDataSource();
dataSource.setServerName(HOST);
dataSource.setDatabaseName(dbName == null ? SETUP_DATABASE_NAME : dbName);
dataSource.setUser(USER);
if (PASS != null)
{
dataSource.setPassword(PASS);
}
return dataSource;
}
}
|