1
14
15 package com.liferay.portal.kernel.util;
16
17 import com.liferay.portal.kernel.dao.db.DB;
18 import com.liferay.portal.kernel.dao.db.DBFactoryUtil;
19
20 import java.io.IOException;
21
22 import java.sql.SQLException;
23
24 import javax.naming.NamingException;
25
26
33 public class DatabaseUtil {
34
35 public static Database getDatabase() {
36 if (_database != null) {
37 return _database;
38 }
39
40 _database = new Database() {
41
42 public String getType() {
43 DB db = DBFactoryUtil.getDB();
44
45 return db.getType();
46 }
47
48 public void runSQLTemplate(String path)
49 throws IOException, NamingException, SQLException {
50
51 DB db = DBFactoryUtil.getDB();
52
53 db.runSQLTemplate(path);
54 }
55
56 public void runSQLTemplate(String path, boolean failOnError)
57 throws IOException, NamingException, SQLException {
58
59 DB db = DBFactoryUtil.getDB();
60
61 db.runSQLTemplate(path, failOnError);
62 }
63
64 };
65
66 return _database;
67 }
68
69 public static String getType() {
70 return getDatabase().getType();
71 }
72
73 public static void runSQLTemplate(String path)
74 throws IOException, NamingException, SQLException {
75
76 getDatabase().runSQLTemplate(path);
77 }
78
79 public static void runSQLTemplate(String path, boolean failOnError)
80 throws IOException, NamingException, SQLException {
81
82 getDatabase().runSQLTemplate(path, failOnError);
83 }
84
85 public void setDatabase(Database database) {
86 _database = database;
87 }
88
89 private static Database _database;
90
91 }