001
014
015 package com.liferay.portal.kernel.util;
016
017 import com.liferay.portal.kernel.dao.db.DB;
018 import com.liferay.portal.kernel.dao.db.DBFactoryUtil;
019
020 import java.io.IOException;
021
022 import java.sql.SQLException;
023
024 import javax.naming.NamingException;
025
026
031 @Deprecated
032 public class DatabaseUtil {
033
034 public static Database getDatabase() {
035 if (_database != null) {
036 return _database;
037 }
038
039 _database = new Database() {
040
041 @Override
042 public String getType() {
043 DB db = DBFactoryUtil.getDB();
044
045 return db.getType();
046 }
047
048 @Override
049 public void runSQLTemplate(String path)
050 throws IOException, NamingException, SQLException {
051
052 DB db = DBFactoryUtil.getDB();
053
054 db.runSQLTemplate(path);
055 }
056
057 @Override
058 public void runSQLTemplate(String path, boolean failOnError)
059 throws IOException, NamingException, SQLException {
060
061 DB db = DBFactoryUtil.getDB();
062
063 db.runSQLTemplate(path, failOnError);
064 }
065
066 };
067
068 return _database;
069 }
070
071 public static String getType() {
072 return getDatabase().getType();
073 }
074
075 public static void runSQLTemplate(String path)
076 throws IOException, NamingException, SQLException {
077
078 getDatabase().runSQLTemplate(path);
079 }
080
081 public static void runSQLTemplate(String path, boolean failOnError)
082 throws IOException, NamingException, SQLException {
083
084 getDatabase().runSQLTemplate(path, failOnError);
085 }
086
087 public void setDatabase(Database database) {
088 _database = database;
089 }
090
091 private static Database _database;
092
093 }