FR [ 1884435 ] Add more DB.getSQLValue helper methods

This commit is contained in:
teo_sarca 2008-02-01 20:34:30 +00:00
parent 567288fbae
commit b323065f13
1 changed files with 57 additions and 0 deletions

View File

@ -30,6 +30,7 @@ import java.sql.Statement;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level; import java.util.logging.Level;
@ -1230,6 +1231,20 @@ public final class DB
return retValue; return retValue;
} }
/**
* Get int Value from sql
* @param trxName trx
* @param sql sql
* @param params collection of parameters
* @return first value or null
*/
public static int getSQLValue (String trxName, String sql, Collection<Object> params)
{
Object[] arr = new Object[params.size()];
params.toArray(arr);
return getSQLValue(trxName, sql, arr);
}
/** /**
* Get String Value from sql * Get String Value from sql
* @param trxName trx * @param trxName trx
@ -1302,6 +1317,20 @@ public final class DB
return retValue; return retValue;
} }
/**
* Get String Value from sql
* @param trxName trx
* @param sql sql
* @param params collection of parameters
* @return first value or null
*/
public static String getSQLValueString (String trxName, String sql, Collection<Object> params)
{
Object[] arr = new Object[params.size()];
params.toArray(arr);
return getSQLValueString(trxName, sql, arr);
}
/** /**
* Get BigDecimal Value from sql * Get BigDecimal Value from sql
* @param trxName trx * @param trxName trx
@ -1374,6 +1403,20 @@ public final class DB
return retValue; return retValue;
} }
/**
* Get BigDecimal Value from sql
* @param trxName trx
* @param sql sql
* @param params collection of parameters
* @return first value or null
*/
public static BigDecimal getSQLValueBD (String trxName, String sql, Collection<Object> params)
{
Object[] arr = new Object[params.size()];
params.toArray(arr);
return getSQLValueBD(trxName, sql, arr);
}
/** /**
* Get Timestamp Value from sql * Get Timestamp Value from sql
* @param trxName trx * @param trxName trx
@ -1410,6 +1453,20 @@ public final class DB
return retValue; return retValue;
} }
/**
* Get Timestamp Value from sql
* @param trxName trx
* @param sql sql
* @param params collection of parameters
* @return first value or null
*/
public static Timestamp getSQLValueTS (String trxName, String sql, Collection<Object> params)
{
Object[] arr = new Object[params.size()];
params.toArray(arr);
return getSQLValueTS(trxName, sql, arr);
}
/** /**
* Get Array of Key Name Pairs * Get Array of Key Name Pairs
* @param sql select with id / name as first / second column * @param sql select with id / name as first / second column