net.sf.jso.sql
Interface DatabaseInterface

All Known Implementing Classes:
JSODatabase

public interface DatabaseInterface

Interface for a relational database management system.


Method Summary
 java.sql.Connection connect(java.lang.String anUrl, java.lang.String anUser, java.lang.String aPassword)
          Connects to the database.
 void createTable(TableDescriptor aTable, java.sql.Connection aConnection)
          Creates a table in the database.
 void dropTable(java.lang.String aTable, java.sql.Connection aConnection)
          Drops a table in the database.
 java.lang.String getDriverClass()
          Returns database's JDBC driver class name.
 int getStringLength()
          Returns the length to be used as string comlumns length in tables.
 boolean isDuplicateKeyCode(int aCode)
          Indicates if a vendor error code is a duplicate key error code.
 boolean isReferentialIntegrityCode(int aCode)
          Indicates if a vendor error code is a referential integrity error code.
 boolean mapTypes(java.sql.Connection aConnection)
          Maps JDBC SQL types to database data types.
 boolean mapTypes(java.io.InputStream aStream)
          Maps JDBC SQL types to database data types.
 boolean mapTypes(java.util.Properties properties)
          Maps JDBC SQL types to database data types.
 boolean set(java.io.InputStream aStream)
          Sets database properties.
 boolean set(java.util.Properties properties)
          Sets database properties.
 void setDriverClass(java.lang.String className)
          Sets database's JDBC driver class name.
 void setDuplicateKeyCodes(java.lang.String codes)
          Sets SQL error codes for duplicate keys.
 void setReferentialIntegrityCodes(java.lang.String codes)
          Sets SQL error codes for referential integrity errors.
 void setStringLength(int someLength)
          Sets the length to be used as string comlumns length in tables.
 void setStringLength(java.lang.String someLength)
          Sets the length to be used as string comlumns length in tables.
 boolean tableExists(java.lang.String aTable, java.sql.Connection aConnection)
          Checks for table existence.
 

Method Detail

set

public boolean set(java.io.InputStream aStream)
            throws java.io.IOException
Sets database properties.

Parameters:
aStream - Input stream of a properties file.
Returns:
true if all mandatory properties could be set; false otherwise.
Throws:
java.io.IOException
See Also:
Properties.load(InputStream), set(Properties)

set

public boolean set(java.util.Properties properties)
Sets database properties. The following properties should be used:

Also, database data types shoul be mapped to JDBC types. The following properties should contain the names of the database data types corresponding to the property JDBC type:

Parameters:
properties - Properties from which database properties will be set.
Returns:
true if all mandatory properties could be set; false otherwise.

setDriverClass

public void setDriverClass(java.lang.String className)
Sets database's JDBC driver class name.

Parameters:
className - Fully qualified name for the JDBC driver class.

getDriverClass

public java.lang.String getDriverClass()
Returns database's JDBC driver class name.

Returns:
Fully qualified name for the JDBC driver class.

setStringLength

public void setStringLength(java.lang.String someLength)
Sets the length to be used as string comlumns length in tables.

Parameters:
someLength - String comlumns length in tables.

setStringLength

public void setStringLength(int someLength)
Sets the length to be used as string comlumns length in tables.

Parameters:
someLength - String comlumns length in tables.

getStringLength

public int getStringLength()
Returns the length to be used as string comlumns length in tables.

Returns:
The length to be used as string comlumns length in tables.

mapTypes

public boolean mapTypes(java.sql.Connection aConnection)
                 throws java.sql.SQLException
Maps JDBC SQL types to database data types.

Parameters:
aConnection - Connection from which data type metadata will be retrieved.
Returns:
true if all necessary jdbc types could be mapped or false otherwise.
Throws:
java.sql.SQLException

mapTypes

public boolean mapTypes(java.io.InputStream aStream)
                 throws java.io.IOException
Maps JDBC SQL types to database data types.

Parameters:
aStream - Input stream of a properties file.
Returns:
true if all necessary jdbc types could be mapped or false otherwise.
Throws:
java.io.IOException
See Also:
Properties.load(InputStream), mapTypes(Properties)

mapTypes

public boolean mapTypes(java.util.Properties properties)
Maps JDBC SQL types to database data types.

Parameters:
properties - Properties from which data type metadata will be retrieved.
Returns:
true if all necessary jdbc types could be mapped or false otherwise.
See Also:
set(Properties)

createTable

public void createTable(TableDescriptor aTable,
                        java.sql.Connection aConnection)
                 throws java.sql.SQLException
Creates a table in the database.

Parameters:
aTable - The table descriptor of the table to be created.
aConnection - A connection to the database.
Throws:
java.sql.SQLException

tableExists

public boolean tableExists(java.lang.String aTable,
                           java.sql.Connection aConnection)
                    throws java.sql.SQLException
Checks for table existence.

Parameters:
aTable - The table name.
aConnection - A connection to the database.
Throws:
java.sql.SQLException

dropTable

public void dropTable(java.lang.String aTable,
                      java.sql.Connection aConnection)
               throws java.sql.SQLException
Drops a table in the database.

Parameters:
aTable - The table name.
aConnection - A connection to the database.
Throws:
java.sql.SQLException

setDuplicateKeyCodes

public void setDuplicateKeyCodes(java.lang.String codes)
                          throws java.lang.IllegalArgumentException
Sets SQL error codes for duplicate keys.

Parameters:
codes - String containing numeric error codes separated by commas.
Throws:
java.lang.IllegalArgumentException

isDuplicateKeyCode

public boolean isDuplicateKeyCode(int aCode)
Indicates if a vendor error code is a duplicate key error code.

Parameters:
aCode - Vendor error code.
Returns:
true if the supplied code is a duplicate key error code; false

setReferentialIntegrityCodes

public void setReferentialIntegrityCodes(java.lang.String codes)
                                  throws java.lang.IllegalArgumentException
Sets SQL error codes for referential integrity errors.

Parameters:
codes - String containing numeric error codes separated by commas.
Throws:
java.lang.IllegalArgumentException

isReferentialIntegrityCode

public boolean isReferentialIntegrityCode(int aCode)
Indicates if a vendor error code is a referential integrity error code.

Parameters:
aCode - Vendor error code.
Returns:
true if the supplied code is a referential integrity error code; false

connect

public java.sql.Connection connect(java.lang.String anUrl,
                                   java.lang.String anUser,
                                   java.lang.String aPassword)
                            throws java.sql.SQLException
Connects to the database.

Parameters:
anUrl - A database url of the form jdbc:subprotocol:subname.
anUser - The database user on whose behalf the connections will be made.
aPassword - The user's password.
Throws:
java.sql.SQLException