Class PostgreSQLDriver

java.lang.Object
fr.inria.rules.integraal.storage.external.rdbms.driver.PostgreSQLDriver
All Implemented Interfaces:
RDBMSDriver

public class PostgreSQLDriver extends Object implements RDBMSDriver
Driver for PostgreSQL databases
  • Constructor Details

    • PostgreSQLDriver

      public PostgreSQLDriver(String host, String dbName, String user, String password) throws org.postgresql.util.PSQLException
      Creates a new driver using the given parameters
      Parameters:
      host - the url of the database
      dbName - the name of the database
      user - the username used to connect to the database
      password - the password used to connect to the database
      Throws:
      org.postgresql.util.PSQLException - iff some error occur
    • PostgreSQLDriver

      public PostgreSQLDriver(String uri) throws org.postgresql.util.PSQLException
      Creates a new driver over the given jdbc string
      Parameters:
      uri - jdbc string
      Throws:
      org.postgresql.util.PSQLException - iff some error occur
  • Method Details

    • getJDBCString

      public String getJDBCString()
      Description copied from interface: RDBMSDriver
      Returns the JDBC connection string.
      Specified by:
      getJDBCString in interface RDBMSDriver
      Returns:
      the jdbc connection string
    • getDatasource

      public DataSource getDatasource()
      Description copied from interface: RDBMSDriver
      Returns the data source handled by this driver.
      Specified by:
      getDatasource in interface RDBMSDriver
      Returns:
      the DataSource represented by this driver
    • getConnection

      public Connection getConnection()
      Description copied from interface: RDBMSDriver
      A driver may keep a connection open in order to execute queries faster or create a new one each time Returns a JDBC connection to the target database.
      Specified by:
      getConnection in interface RDBMSDriver
      Returns:
      a Connection for the database represented by this driver
    • getBaseSafeInsertQuery

      public String getBaseSafeInsertQuery()
      Description copied from interface: RDBMSDriver
      Returns the base safe INSERT query template.
      Specified by:
      getBaseSafeInsertQuery in interface RDBMSDriver
      Returns:
      the base INSERT query which does not create exceptions in case of duplicates corresponding to this driver
    • getBaseSafeInsertSelectQuery

      public String getBaseSafeInsertSelectQuery()
      Description copied from interface: RDBMSDriver
      Returns the safe INSERT-SELECT query template.
      Specified by:
      getBaseSafeInsertSelectQuery in interface RDBMSDriver
      Returns:
      the base INSERT query using a SELECT clause which does not create exceptions in case of duplicates corresponding to this driver
    • getTextFieldName

      public String getTextFieldName()
      Description copied from interface: RDBMSDriver
      Returns the SQL text-column type name used by this driver.
      Specified by:
      getTextFieldName in interface RDBMSDriver
      Returns:
      the name of the Text field corresponding to this driver
    • getNumberFieldName

      public String getNumberFieldName()
      Description copied from interface: RDBMSDriver
      Returns the SQL numeric-column type name used by this driver.
      Specified by:
      getNumberFieldName in interface RDBMSDriver
      Returns:
      the name of the Number field corresponding to this driver
    • getCSVCopyQuery

      public String getCSVCopyQuery(String tableName, String csvFilePath, char delimiter, int headerSize)
      Description copied from interface: RDBMSDriver
      Returns the SQL query used to bulk-copy CSV data.
      Specified by:
      getCSVCopyQuery in interface RDBMSDriver
      Parameters:
      tableName - table name to store data
      csvFilePath - path to the csv file
      delimiter - delimiter of the csv file
      headerSize - size of the csv header
      Returns:
      the query used to copy a CSV file into the database system
    • dropAllTables

      public void dropAllTables() throws SQLException
      Clears all tables in the database by truncating them.
      Specified by:
      dropAllTables in interface RDBMSDriver
      Throws:
      SQLException - If an error occurs during database access.