1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.application.db;
14 import java.util.Properties;
16 import org.simantics.db.Driver;
17 import org.simantics.db.Manager;
18 import org.simantics.db.Session;
19 import org.simantics.db.services.GlobalServiceInitializer;
21 public final class DatabaseUtils {
23 // public static Session connect(String host, int port) throws Exception {
24 // return connect(new ServerAddress(host, port));
27 // public static Session connect(String host, int port, String dbid) throws Exception {
28 // return connect(new ServerAddress(host, port, dbid));
31 public static Session connect(String addr) throws Exception {
32 // Try to load and register the Driver instance with the driver manager
33 Class.forName("org.simantics.db.procore.ProCoreDriver");
34 Driver driver = Manager.getDriver("procore");
36 // Connect to the server at the specified host and credentials.
37 // Note that we normally user authentication agent for user identification.
38 Properties props = new Properties();
39 props.setProperty("user", "Default User");
40 props.setProperty("password", "");
42 Session session = driver.getSession(addr, props);
44 new GlobalServiceInitializer().initialize(session);