2 * Copyright 2016 ZTE Corporation.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.onap.aai.esr.db.util;
18 import org.apache.tools.ant.Project;
19 import org.apache.tools.ant.taskdefs.SQLExec;
20 import org.apache.tools.ant.types.EnumeratedAttribute;
23 import java.net.URISyntaxException;
26 public class H2DbServerUtil {
27 private static String resourcePath;
32 public static void initTable() {
34 SQLExec sqlExec = new SQLExec();
35 // set db connetc parameter
36 sqlExec.setDriver("org.h2.Driver");
37 sqlExec.setUrl("jdbc:h2:tcp://localhost:18209/" + resourcePath + "db/extsys");
38 sqlExec.setUserid("extsys");
39 sqlExec.setPassword("extsys");
41 sqlExec.setSrc(new File(resourcePath + "sql/extsys-resource-createObj-mysql.sql"));
43 (SQLExec.OnError) (EnumeratedAttribute.getInstance(SQLExec.OnError.class, "abort")));
44 sqlExec.setPrint(true); // set print
45 sqlExec.setProject(new Project());
49 private static void init() {
51 resourcePath = HibernateSession.class.getResource("/").toURI().getPath();
52 } catch (URISyntaxException error) {
53 error.printStackTrace();
60 public static void main(String [] args) {
62 H2DbServerUtil.initTable();
63 H2DbServer.shutDown();