openlsd.database.session
Class LSDDbRequest

java.lang.Object
  extended by openlsd.database.session.LSDDbRequest

public class LSDDbRequest
extends java.lang.Object

Class to handle request

Author:
Frederic Bregier LGPL

Constructor Summary
LSDDbRequest(LSDDbSession ls)
          Create a new request from the LSDDbSession
 
Method Summary
 void close()
          Finished a Request (ready for a new one)
static java.lang.String getIsNull(java.lang.String value)
          Test if value is null and create the string for insert/update
 long getLastId()
          Get the last ID autoincrement from the last request
static long getLastId(java.sql.ResultSet resultSet)
          Get the last ID autoincrement from the result
static boolean getNext(java.sql.ResultSet resultSet)
          Move the cursor to the next result
 int query(java.lang.String query)
          Execute a UPDATE/INSERT/DELETE statement and returns the number of row or -1 if an error occurs The previous statement and resultSet are closed.
 java.sql.ResultSet select(java.lang.String select)
          Execute a SELECT statement and returns the set of Result.
 java.sql.ResultSet select(java.lang.String select, int nbFetch)
          Execute a SELECT statement and returns the set of Result.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LSDDbRequest

public LSDDbRequest(LSDDbSession ls)
Create a new request from the LSDDbSession

Parameters:
ls -
Method Detail

select

public java.sql.ResultSet select(java.lang.String select)
Execute a SELECT statement and returns the set of Result. The statement must not be an update/insert/delete, since it will return null, as if an error occurs. The previous statement and resultSet are closed.

Parameters:
select -
Returns:
the set of Result or null if an error occurs

select

public java.sql.ResultSet select(java.lang.String select,
                                 int nbFetch)
Execute a SELECT statement and returns the set of Result. The statement must not be an update/insert/delete, since it will return null, as if an error occurs. The previous statement and resultSet are closed.

Parameters:
select -
nbFetch - the number of pre fetch rows
Returns:
the set of Result or null if an error occurs

query

public int query(java.lang.String query)
Execute a UPDATE/INSERT/DELETE statement and returns the number of row or -1 if an error occurs The previous statement and resultSet are closed.

Parameters:
query -
Returns:
the number of row in the query

close

public void close()
Finished a Request (ready for a new one)


getLastId

public long getLastId()
Get the last ID autoincrement from the last request

Returns:
the long Id or LSDConstant.invalide_idx (Long.MIN_VALUE) if an error occurs.

getLastId

public static long getLastId(java.sql.ResultSet resultSet)
Get the last ID autoincrement from the result

Parameters:
resultSet -
Returns:
the long Id or LSDConstant.invalide_idx (Long.MIN_VALUE) if an error occurs.

getNext

public static boolean getNext(java.sql.ResultSet resultSet)
Move the cursor to the next result

Parameters:
resultSet -
Returns:
True if there is a next result, else False

getIsNull

public static java.lang.String getIsNull(java.lang.String value)
Test if value is null and create the string for insert/update

Parameters:
value -
Returns:
the string as result