Compiere 3.1

org.compiere.sqlj
Class Compiere

java.lang.Object
  extended by org.compiere.sqlj.Compiere
All Implemented Interfaces:
Serializable

public class Compiere
extends Object
implements Serializable

SQLJ Compiere Control and Utility Class

Version:
$Id$
Author:
Jorg Janke
See Also:
Serialized Form

Field Summary
static BigDecimal HUNDRED
          Hundred 100
static BigDecimal ONE
          One 1
protected static String s_pwd
          Connection Password
static String s_type
          Server Type
protected static String s_uid
          Connection User
protected static String s_url
          Connection URL
static String TRUNC_DAY
          Truncate Day - D
static String TRUNC_MONTH
          Truncate Month - MM
static String TRUNC_QUARTER
          Truncate Quarter - Q
static String TRUNC_WEEK
          Truncate Week - W
static String TRUNC_YEAR
          Truncate Year - Y
static String TYPE_DB2
          DB2 Server
static String TYPE_ORACLE
          Oracle Server
static BigDecimal ZERO
          Zero 0
 
Constructor Summary
Compiere()
           
 
Method Summary
static Timestamp addDays(Timestamp day, int offset)
          Return Day + offset (truncates)
static String charAt(String source, int posIndex)
          Character At Position
static Timestamp firstOf(Timestamp p_dateTime, String XX)
          Fist of Date
static String getChars(BigDecimal d)
          To Characters
static Timestamp getDate()
          Mext ID
static int getDaysBetween(Timestamp start, Timestamp end)
          Calculate the number of days between start and end.
static String getProperties()
          Get Environment Info
static String getProperty(String key)
          Get Environment Info
static String getServerType()
          Get Server Type
static String getVersion()
          Get Version
static Timestamp nextBusinessDay(Timestamp day)
          Next Business Day.
static String Time2Chars(Timestamp t)
          get chars from a number
protected static Timestamp trunc(Timestamp t)
          Truncate Date
static Timestamp trunc(Timestamp dayTime, String trunc)
          Get truncated day/time
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE_ORACLE

public static final String TYPE_ORACLE
Oracle Server

See Also:
Constant Field Values

TYPE_DB2

public static final String TYPE_DB2
DB2 Server

See Also:
Constant Field Values

s_type

public static String s_type
Server Type


s_url

protected static String s_url
Connection URL


s_uid

protected static String s_uid
Connection User


s_pwd

protected static String s_pwd
Connection Password


ZERO

public static final BigDecimal ZERO
Zero 0


ONE

public static final BigDecimal ONE
One 1


HUNDRED

public static final BigDecimal HUNDRED
Hundred 100


TRUNC_DAY

public static final String TRUNC_DAY
Truncate Day - D

See Also:
Constant Field Values

TRUNC_WEEK

public static final String TRUNC_WEEK
Truncate Week - W

See Also:
Constant Field Values

TRUNC_MONTH

public static final String TRUNC_MONTH
Truncate Month - MM

See Also:
Constant Field Values

TRUNC_QUARTER

public static final String TRUNC_QUARTER
Truncate Quarter - Q

See Also:
Constant Field Values

TRUNC_YEAR

public static final String TRUNC_YEAR
Truncate Year - Y

See Also:
Constant Field Values
Constructor Detail

Compiere

public Compiere()
Method Detail

getVersion

public static String getVersion()
Get Version

Returns:
version

getProperties

public static String getProperties()
Get Environment Info

Returns:
properties

getProperty

public static String getProperty(String key)
                          throws SQLException
Get Environment Info

Parameters:
key - key
Returns:
property info
Throws:
SQLException

getServerType

public static String getServerType()
Get Server Type

Returns:
server type

trunc

public static Timestamp trunc(Timestamp dayTime,
                              String trunc)
Get truncated day/time

Parameters:
dayTime - day
trunc - how to truncate TRUNC_*
Returns:
next day with 00:00

trunc

protected static Timestamp trunc(Timestamp t)
Truncate Date

Parameters:
t - time
Returns:
day

firstOf

public static Timestamp firstOf(Timestamp p_dateTime,
                                String XX)
Fist of Date

Parameters:
p_dateTime - date
XX - date part - Supported: DD(default),DY,MM,Q
Returns:
day (first)

getDaysBetween

public static int getDaysBetween(Timestamp start,
                                 Timestamp end)
Calculate the number of days between start and end.

Parameters:
start - start date
end - end date
Returns:
number of days (0 = same)

addDays

public static Timestamp addDays(Timestamp day,
                                int offset)
Return Day + offset (truncates)

Parameters:
day - Day
offset - day offset
Returns:
Day + offset at 00:00

nextBusinessDay

public static Timestamp nextBusinessDay(Timestamp day)
Next Business Day. (Only Sa/Su -> Mo)

Parameters:
day - day
Returns:
next business dat if day is "off"

charAt

public static String charAt(String source,
                            int posIndex)
Character At Position

Parameters:
source - source
posIndex - position 1 = first
Returns:
substring or null

getDate

public static Timestamp getDate()
Mext ID

Parameters:
AD_Sequence_ID - sequence
System - system
Returns:
ID or -1
Throws:
SQLException - public static int nextID (int AD_Sequence_ID, String System) throws SQLException { boolean isSystem = System != null && "Y".equals(System); int retValue = -1; StringBuffer sql = new StringBuffer ("SELECT CurrentNext"); if (isSystem) sql.append("Sys"); sql.append(",IncrementNo FROM AD_Sequence WHERE AD_Sequence_ID=? FOR UPDATE"); PreparedStatement pstmt = prepareStatement(sql.toString(), ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE); ResultSet rs = pstmt.executeQuery(); if (rs.next()) { retValue = rs.getInt(1); int incrementNo = rs.getInt(2); //jz retValue += incrementNo; rs.updateInt(2, retValue); //pstmt.getConnection().commit(); } rs.close(); pstmt.close(); // return retValue; } // nextID /* ProcNextID is a procedure version of nextID Since Derby could not tell diff of signatures, use ProcNextID public static void ProcNextID (int AD_Sequence_ID, String System, int[] retVal) throws SQLException { retVal[0] = nextID(AD_Sequence_ID, System); } /** Get current Date (Timestamp)

getChars

public static String getChars(BigDecimal d)
To Characters

Parameters:
d - double
Returns:
String

Time2Chars

public static String Time2Chars(Timestamp t)
get chars from a number

Parameters:
d - double
Returns:
String

Compiere 3.1

Compiere® is a registered trademark of ComPiere, Inc. ©2004-2008 HumanFlash.com All rights reserved.