org.salespointframework.core.data.database
Class SqliteDatabaseConnection

java.lang.Object
  extended by org.salespointframework.core.data.database.SqliteDatabaseConnection
All Implemented Interfaces:
DatabaseConnection

public class SqliteDatabaseConnection
extends java.lang.Object
implements DatabaseConnection

This is the implementation of DatabaseConnection for Sqlite 3 databases

Author:
Tom

Nested Class Summary
private  class SqliteDatabaseConnection.SqliteConfigurationDialog
          config dialog for sqlite connections
private  class SqliteDatabaseConnection.SqliteConfigurationFS
          config FormSheet for sqlite connections
 
Field Summary
protected  java.util.Map<java.lang.String,java.lang.String> cmds
          special command for this connections
protected  java.lang.String description
          connection's description
protected  java.lang.String filename
          filename of database
protected  java.lang.String imageFilename
          filename of connection image
protected  java.lang.String name
          name of connection
protected  java.util.Map<java.lang.String,java.lang.String> typeMap
          type map which maps java types to sql types
 
Constructor Summary
SqliteDatabaseConnection()
          default constrcutor which initializes type map and special commands
 
Method Summary
 boolean beforeConnect()
          nothing to do before connect
 void configure(java.awt.Window owner)
          displays the config dialog
 java.lang.Object doAssignmentFixing(java.lang.Class target, java.lang.Object obj)
          nothing to fix
 java.util.Properties getConnectionProperties()
          returns connection properties
 java.lang.String getConnectionString()
          returns the connection string
 java.lang.String getDescription()
          retuns connection's description
 java.awt.image.BufferedImage getImage()
          loads the image given by imageFilename and returns it
 java.lang.String getName()
          returns connections name
 java.util.Map<java.lang.String,java.lang.String> getSpecialCommands()
          returns cmds
 java.util.Map<java.lang.String,java.lang.String> getTableColumns(java.sql.Statement st, java.lang.String tname)
          get a map of table columns mapped to their types for given table
 java.util.List<java.lang.String> getTables(java.sql.Statement st)
          returns a list of all table sin database
 java.util.Map<java.lang.String,java.lang.String> getTypeMapping()
          returns typeMap
 boolean handleCreateTableException(java.sql.SQLException e)
          nothing to handle
 boolean loadDriver()
          loads database driver. in this case: org.sqlite.JDBC
 void onClose()
          nothing to do on close
 boolean onConnected(java.sql.Connection con)
          sets DefaultClassNameEncoder mode to Hash mode.
 void recover(java.util.Map<java.lang.String,java.lang.String> data)
          recovers connection properties
 java.util.Map<java.lang.String,java.lang.String> save()
          saves connection properties
 boolean supportsAutoGeneratedKeys()
          returns false
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

typeMap

protected java.util.Map<java.lang.String,java.lang.String> typeMap
type map which maps java types to sql types


cmds

protected java.util.Map<java.lang.String,java.lang.String> cmds
special command for this connections


name

protected java.lang.String name
name of connection


description

protected java.lang.String description
connection's description


filename

protected java.lang.String filename
filename of database


imageFilename

protected java.lang.String imageFilename
filename of connection image

Constructor Detail

SqliteDatabaseConnection

public SqliteDatabaseConnection()
default constrcutor which initializes type map and special commands

Method Detail

configure

public void configure(java.awt.Window owner)
displays the config dialog

Specified by:
configure in interface DatabaseConnection
Parameters:
owner - owning window

supportsAutoGeneratedKeys

public boolean supportsAutoGeneratedKeys()
returns false

Specified by:
supportsAutoGeneratedKeys in interface DatabaseConnection
Returns:
See Also:
DatabaseConnection.supportsAutoGeneratedKeys()

getConnectionString

public java.lang.String getConnectionString()
returns the connection string

Specified by:
getConnectionString in interface DatabaseConnection
Returns:
connection string
See Also:
DriverManager.getConnection(String, Properties)

getDescription

public java.lang.String getDescription()
retuns connection's description

Specified by:
getDescription in interface DatabaseConnection
Returns:
connection description

getName

public java.lang.String getName()
returns connections name

Specified by:
getName in interface DatabaseConnection
Returns:
connection name

getTypeMapping

public java.util.Map<java.lang.String,java.lang.String> getTypeMapping()
returns typeMap

Specified by:
getTypeMapping in interface DatabaseConnection
Returns:
type mapping

loadDriver

public boolean loadDriver()
loads database driver. in this case: org.sqlite.JDBC

Specified by:
loadDriver in interface DatabaseConnection
Returns:
true on success

getImage

public java.awt.image.BufferedImage getImage()
loads the image given by imageFilename and returns it

Specified by:
getImage in interface DatabaseConnection
Returns:
image

recover

public void recover(java.util.Map<java.lang.String,java.lang.String> data)
recovers connection properties

Specified by:
recover in interface DatabaseConnection
Parameters:
data - recovered properties

save

public java.util.Map<java.lang.String,java.lang.String> save()
saves connection properties

Specified by:
save in interface DatabaseConnection
Returns:
connection properties

onConnected

public boolean onConnected(java.sql.Connection con)
sets DefaultClassNameEncoder mode to Hash mode. disables sqlite journal mode because of problems due update, insert and delete sets cache size to 2000

Specified by:
onConnected in interface DatabaseConnection
Parameters:
con - connection which was established
Returns:
true on success

getSpecialCommands

public java.util.Map<java.lang.String,java.lang.String> getSpecialCommands()
returns cmds

Specified by:
getSpecialCommands in interface DatabaseConnection
Returns:

beforeConnect

public boolean beforeConnect()
nothing to do before connect

Specified by:
beforeConnect in interface DatabaseConnection
Returns:
true on success

getTables

public java.util.List<java.lang.String> getTables(java.sql.Statement st)
returns a list of all table sin database

Specified by:
getTables in interface DatabaseConnection
Parameters:
st - statement to use. closed by PersistenceManager

getTableColumns

public java.util.Map<java.lang.String,java.lang.String> getTableColumns(java.sql.Statement st,
                                                                        java.lang.String tname)
Description copied from interface: DatabaseConnection
get a map of table columns mapped to their types for given table

Specified by:
getTableColumns in interface DatabaseConnection
Parameters:
st - statement to use. closed by PersistenceManager
tname - table to examine
Returns:
columns -> type map

getConnectionProperties

public java.util.Properties getConnectionProperties()
returns connection properties

Specified by:
getConnectionProperties in interface DatabaseConnection
Returns:
list of properties
See Also:
DriverManager.getConnection(String, Properties)

onClose

public void onClose()
nothing to do on close

Specified by:
onClose in interface DatabaseConnection

handleCreateTableException

public boolean handleCreateTableException(java.sql.SQLException e)
nothing to handle

Specified by:
handleCreateTableException in interface DatabaseConnection
Parameters:
e - caught exception
Returns:
true if expception was handled here. otherwise false and PersistenceManager will throw a RuntimeException

doAssignmentFixing

public java.lang.Object doAssignmentFixing(java.lang.Class target,
                                           java.lang.Object obj)
nothing to fix

Specified by:
doAssignmentFixing in interface DatabaseConnection
Parameters:
target - target type
obj - object which will be assigned afterwards
Returns:
fixed object