📄 databasepolicy.java
字号:
/*
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
*
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations under
* the License.
*
* The Original Code is jRelationalFramework.
*
* The Initial Developer of the Original Code is is.com.
* Portions created by is.com are Copyright (C) 2000 is.com.
* All Rights Reserved.
*
* Contributor(s): Jonathan Carlson (joncrlsn@users.sf.net)
* Contributor(s): ____________________________________
*
* Alternatively, the contents of this file may be used under the terms of
* the GNU General Public License (the "GPL") or the GNU Lesser General
* Public license (the "LGPL"), in which case the provisions of the GPL or
* LGPL are applicable instead of those above. If you wish to allow use of
* your version of this file only under the terms of either the GPL or LGPL
* and not to allow others to use your version of this file under the MPL,
* indicate your decision by deleting the provisions above and replace them
* with the notice and other provisions required by either the GPL or LGPL
* License. If you do not delete the provisions above, a recipient may use
* your version of this file under either the MPL or GPL or LGPL License.
*
*/
package com.is.jrf;
import com.is.util.sql.JDBCHelper;
import java.sql.Timestamp;
import java.sql.SQLException;
/**
* This is an interface used to provide database specific behavior. An
* implementer of this is referenced by the AbstractDomain.
*
* @see OracleDatabasePolicy
* @see SQLServerSybaseDatabasePolicy
*/
public interface DatabasePolicy
{
/* =============== Abstract Methods =============== */
/**
* Return a SQL string to get the next sequence number for a table. When
* executed, this SQL should return a one column, one row result set with
* an integer.
*
* @param tableName a value of type 'String'
* @return a value of type 'String'
*/
public String sequenceSQL(String tableName);
/**
* This method creates a sequence for the domain object. If the sequence
* already exists, it will be reset to the beginning (usually 0).
*
* @param domain a value of type 'AbstractDomain'
* @param aJDBCHelper a value of type 'JDBCHelper'
* @exception SQLException if an error occurs
*/
public void createSequence(AbstractDomain domain,
JDBCHelper aJDBCHelper)
throws SQLException;
/**
* This should return the string value (function name) to put into the SQL
* to tell the database to insert the current timestamp.
*
* @return a value of type 'String'
*/
public String timestampFunction();
/**
* The return value should be in the string format that the database
* recognizes as a timestamp.
*
* @param ts a value of type 'Timestamp'
* @return a value of type 'String'
*/
public String formatTimestamp(Timestamp ts);
/**
* The result of this is used in SQL. This will format only the date
* (not the time portion)
*
* @param sqlDate a value of type 'java.sql.Date'
* @return a value of type 'String'
*/
public String formatDate(java.sql.Date sqlDate);
/**
* This should return the the SQL to use to have the database
* return the current timestamp.
*
* @return a value of type 'String'
*/
public String currentTimestampSQL();
/**
* auto-increment means that upon insertion, the integer column is
* automatically given a unique id by the dbms.
*
* The auto-increment methods were added for InstantDB, HypsersonicSQL,
* and any other database that uses this instead of traditional
* sequencing methods that occur before insertion.
*/
public String autoIncrementIdentifier();
public Long findAutoIncrementId(String tableName,
String columnName,
JDBCHelper aJDBCHelper);
/**
* Return a string of a name-value pair that represents an SQL outer join
* that can be used in a WHERE clause.
* i.e. The result would look like this for Oracle: 'Tbl1.Id=Tbl2.Id(+)'
*
* @param mainTableColumn a value of type 'String'
* @param joinTableColumn a value of type 'String'
* @return a value of type 'String'
*/
public abstract String outerWhereJoin(String mainTableColumn,
String joinTableColumn);
/**
* This method used when building SQL for creating a table.
*
* @return a value of type 'String'
*/
public String timestampColumnType();
} // DatabasePolicy
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -