com.dynamide.db
Class RDBDatabase

java.lang.Object
  extended by com.dynamide.db.Database
      extended by com.dynamide.db.RDBDatabase

public class RDBDatabase
extends Database


Nested Class Summary
 class RDBDatabase.SQLExecuteResult
           
 
Field Summary
static java.lang.String CONX_MY_SQL
          To use for the Constructor's "uri" parameter, add "/databasename" to this, e.g.
static java.lang.String CONX_POSTGRESQL
          For connection to localhost listening with "postmaster -i" so that it uses internet sockets.
static java.lang.String DRIVER_MY_SQL
           
static java.lang.String DRIVER_MY_SQL_CONNECTORJ
           
static java.lang.String DRIVER_POSTGRESQL
           
protected  StringList m_propertiesTable
           
 
Constructor Summary
RDBDatabase(java.lang.String uri, java.lang.String driverName, java.lang.String username, java.lang.String password, Session session)
           
 
Method Summary
 void close()
           
static java.lang.String escapeForPostgres(java.lang.String val)
           
 RDBDatabase.SQLExecuteResult execute(java.lang.String sql, boolean use_log4j, java.lang.String debugLocation)
           
 RDBDatabase.SQLExecuteResult execute(java.lang.String sql, boolean use_log4j, java.lang.String resultColumn, java.lang.String debugLocation)
           
 RDBDatabase.SQLExecuteResult execute(java.lang.String sql, java.lang.String debugLocation)
           
 RDBDatabase.SQLExecuteResult execute(java.lang.String sql, java.lang.String resultColumn, java.lang.String debugLocation)
           
 java.sql.ResultSet executeQuery(java.lang.String sql, java.lang.String debugLocation)
           
 java.lang.Object executeQueryToObject(java.lang.String sql, java.lang.String column, java.lang.String debugLocation)
          Executes the query and returns the named column value of the first row.
 java.lang.String executeQueryToString(java.lang.String sql, java.lang.String column, java.lang.String debugLocation)
          Uses com.dynamide.util.StringTools.decodeBytea(Object) to decode the result.
 int executeUpdate(java.lang.String sql, java.lang.String debugLocation)
           
 java.sql.Connection getConnection()
           
 java.lang.String getContextName()
           
 boolean getDebugSQL()
           
 java.lang.String getDriverName()
           
 Property getProperty(java.lang.String propertyName)
           
 IPropertyProvider getPropertyProvider()
           
 Session getSession()
           
static RDBDatabase getTestDatabase(java.lang.String user, java.lang.String password)
           
 java.lang.String getURI()
           
 boolean getUseLog4j()
           
 void load(java.lang.String sql, java.lang.String debugLocation)
           
 void logDebugSQL(java.lang.String location, java.lang.String sql)
           
 void logDebugSQLError(java.lang.String location, java.lang.String sql, java.lang.String error)
           
static void main(java.lang.String[] args)
           
 RDBTable openRDBTable(java.lang.String tableName)
           
 org.webmacro.datatable.DataTable readTable(java.lang.String sql, int pageSize, int skipRows, java.lang.String debugLocation)
           
 org.webmacro.datatable.DataTable readTable(java.lang.String sql, java.lang.String debugLocation)
           
 TableTree readTableTree(java.lang.String sql, java.lang.String detailIDColumnName, java.lang.String detailParentIDColumnName, boolean zeroIsNull, int pageSize, int skipRows, java.lang.String debugLocation)
           
 TableTree readTableTree(java.lang.String sql, java.lang.String detailIDColumnName, java.lang.String detailParentIDColumnName, boolean zeroIsNull, java.lang.String debugLocation)
           
 void setContextName(java.lang.String new_value)
           
 void setDebugSQL(boolean new_value)
           
 void setProperty(java.lang.String name, java.lang.String value)
           
 void setPropertyProvider(IPropertyProvider new_value)
           
 void setSession(Session new_value)
           
 void setUseLog4j(boolean new_value)
           
 void test()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CONX_MY_SQL

public static final java.lang.String CONX_MY_SQL
To use for the Constructor's "uri" parameter, add "/databasename" to this, e.g. CONX_MY_SQL+"/mydatabase" .

See Also:
Constant Field Values

CONX_POSTGRESQL

public static final java.lang.String CONX_POSTGRESQL
For connection to localhost listening with "postmaster -i" so that it uses internet sockets. No host and port. Just specify
              new RDBDatabase(RDBDatabase.CONX_POSTGRESQL+"net_roots",
                                    RDBDatabase.DRIVER_MY_SQL_CONNECTORJ,
                              "myuser",
                              "mypassword");
 
Note that postgresql does NOT use the leading slash before the database if no host:port is specified: CORRECT: RDBDatabase.CONX_POSTGRESQL+"net_roots" INCORRECT: RDBDatabase.CONX_POSTGRESQL+"/net_roots"

See Also:
Constant Field Values

DRIVER_MY_SQL

public static final java.lang.String DRIVER_MY_SQL
See Also:
Constant Field Values

DRIVER_MY_SQL_CONNECTORJ

public static final java.lang.String DRIVER_MY_SQL_CONNECTORJ
See Also:
Constant Field Values

DRIVER_POSTGRESQL

public static final java.lang.String DRIVER_POSTGRESQL
See Also:
Constant Field Values

m_propertiesTable

protected StringList m_propertiesTable
Constructor Detail

RDBDatabase

public RDBDatabase(java.lang.String uri,
                   java.lang.String driverName,
                   java.lang.String username,
                   java.lang.String password,
                   Session session)
Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getSession

public Session getSession()

setSession

public void setSession(Session new_value)

getDriverName

public java.lang.String getDriverName()

getURI

public java.lang.String getURI()

getContextName

public java.lang.String getContextName()

setContextName

public void setContextName(java.lang.String new_value)

logDebugSQL

public void logDebugSQL(java.lang.String location,
                        java.lang.String sql)

logDebugSQLError

public void logDebugSQLError(java.lang.String location,
                             java.lang.String sql,
                             java.lang.String error)

getDebugSQL

public boolean getDebugSQL()

setDebugSQL

public void setDebugSQL(boolean new_value)

getUseLog4j

public boolean getUseLog4j()

setUseLog4j

public void setUseLog4j(boolean new_value)

getPropertyProvider

public IPropertyProvider getPropertyProvider()

setPropertyProvider

public void setPropertyProvider(IPropertyProvider new_value)

getProperty

public Property getProperty(java.lang.String propertyName)

setProperty

public void setProperty(java.lang.String name,
                        java.lang.String value)
                 throws DatatypeException
Throws:
DatatypeException

escapeForPostgres

public static java.lang.String escapeForPostgres(java.lang.String val)

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
Throws:
java.sql.SQLException

close

public void close()

readTable

public org.webmacro.datatable.DataTable readTable(java.lang.String sql,
                                                  java.lang.String debugLocation)
                                           throws java.lang.Exception
Throws:
java.lang.Exception

readTable

public org.webmacro.datatable.DataTable readTable(java.lang.String sql,
                                                  int pageSize,
                                                  int skipRows,
                                                  java.lang.String debugLocation)
                                           throws java.lang.Exception
Throws:
java.lang.Exception

readTableTree

public TableTree readTableTree(java.lang.String sql,
                               java.lang.String detailIDColumnName,
                               java.lang.String detailParentIDColumnName,
                               boolean zeroIsNull,
                               java.lang.String debugLocation)
                        throws java.lang.Exception
Throws:
java.lang.Exception

readTableTree

public TableTree readTableTree(java.lang.String sql,
                               java.lang.String detailIDColumnName,
                               java.lang.String detailParentIDColumnName,
                               boolean zeroIsNull,
                               int pageSize,
                               int skipRows,
                               java.lang.String debugLocation)
                        throws java.lang.Exception
Throws:
java.lang.Exception

openRDBTable

public RDBTable openRDBTable(java.lang.String tableName)

execute

public RDBDatabase.SQLExecuteResult execute(java.lang.String sql,
                                            java.lang.String debugLocation)
                                     throws java.sql.SQLException
Returns:
-2 on error, -1 on a ResultSet returned or no count returned, otherwise 0-n for the result of Statement.getUpdateCount().
Throws:
java.sql.SQLException

execute

public RDBDatabase.SQLExecuteResult execute(java.lang.String sql,
                                            java.lang.String resultColumn,
                                            java.lang.String debugLocation)
                                     throws java.sql.SQLException
Throws:
java.sql.SQLException

execute

public RDBDatabase.SQLExecuteResult execute(java.lang.String sql,
                                            boolean use_log4j,
                                            java.lang.String debugLocation)
                                     throws java.sql.SQLException
Throws:
java.sql.SQLException

execute

public RDBDatabase.SQLExecuteResult execute(java.lang.String sql,
                                            boolean use_log4j,
                                            java.lang.String resultColumn,
                                            java.lang.String debugLocation)
                                     throws java.sql.SQLException
Returns:
Integer if count, otherwise String if value or error.
Throws:
java.sql.SQLException

executeQuery

public java.sql.ResultSet executeQuery(java.lang.String sql,
                                       java.lang.String debugLocation)
                                throws java.sql.SQLException
Throws:
java.sql.SQLException

executeQueryToObject

public java.lang.Object executeQueryToObject(java.lang.String sql,
                                             java.lang.String column,
                                             java.lang.String debugLocation)
                                      throws java.sql.SQLException
Executes the query and returns the named column value of the first row.

Throws:
java.sql.SQLException

executeQueryToString

public java.lang.String executeQueryToString(java.lang.String sql,
                                             java.lang.String column,
                                             java.lang.String debugLocation)
                                      throws java.sql.SQLException
Uses com.dynamide.util.StringTools.decodeBytea(Object) to decode the result. This is a Postgres type.

Throws:
java.sql.SQLException

executeUpdate

public int executeUpdate(java.lang.String sql,
                         java.lang.String debugLocation)
                  throws java.sql.SQLException
Throws:
java.sql.SQLException

load

public void load(java.lang.String sql,
                 java.lang.String debugLocation)
          throws java.sql.SQLException
Throws:
java.sql.SQLException

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception

getTestDatabase

public static RDBDatabase getTestDatabase(java.lang.String user,
                                          java.lang.String password)

test

public void test()
          throws java.lang.Exception
Throws:
java.lang.Exception


Copyright 2001-2013 DYNAMIDE.COM. All Rights Reserved.