1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portal.service.impl;
16  
17  import com.liferay.portal.SystemException;
18  import com.liferay.portal.kernel.dao.db.DB;
19  import com.liferay.portal.kernel.dao.db.DBFactoryUtil;
20  import com.liferay.portal.kernel.dao.jdbc.DataAccess;
21  import com.liferay.portal.kernel.log.Log;
22  import com.liferay.portal.kernel.log.LogFactoryUtil;
23  import com.liferay.portal.service.base.QuartzLocalServiceBaseImpl;
24  
25  import java.sql.Connection;
26  import java.sql.PreparedStatement;
27  import java.sql.ResultSet;
28  
29  /**
30   * <a href="QuartzLocalServiceImpl.java.html"><b><i>View Source</i></b></a>
31   *
32   * @author Brian Wing Shun Chan
33   */
34  public class QuartzLocalServiceImpl extends QuartzLocalServiceBaseImpl {
35  
36      public void checkQuartzTables() throws SystemException {
37          Connection con = null;
38          PreparedStatement ps = null;
39          ResultSet rs = null;
40  
41          try {
42              con = DataAccess.getConnection();
43  
44              ps = con.prepareStatement(
45                  "select count(*) from QUARTZ_JOB_DETAILS");
46  
47              rs = ps.executeQuery();
48  
49              if (rs.next()) {
50                  return;
51              }
52          }
53          catch (Exception e) {
54              if (_log.isWarnEnabled()) {
55                  _log.warn(e.getMessage());
56              }
57          }
58          finally {
59              DataAccess.cleanUp(con, ps, rs);
60          }
61  
62          DB db = DBFactoryUtil.getDB();
63  
64          try {
65              db.runSQLTemplate("quartz-tables.sql", false);
66          }
67          catch (Exception e) {
68              throw new SystemException(e);
69          }
70      }
71  
72      private static Log _log = LogFactoryUtil.getLog(
73          QuartzLocalServiceImpl.class);
74  
75  }