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