1. Project Clover database Wed Jan 17 2024 23:40:18 CST
  2. Package org.europa.together.business

File DatabaseActions.java

 

Code metrics

0
0
0
1
87
23
0
-
-
0
-

Classes

Class Line # Actions
DatabaseActions 22 0 - 0 0
-1.0 -
 

Contributing tests

No tests hitting this source file were found.

Source view

1    package org.europa.together.business;
2   
3    import java.sql.ResultSet;
4    import java.sql.SQLException;
5    import org.apiguardian.api.API;
6    import static org.apiguardian.api.API.Status.STABLE;
7    import org.europa.together.domain.JdbcConnection;
8    import org.springframework.stereotype.Component;
9   
10    /**
11    * DatabaseActions is a simple helper class to execute SQL queries and other
12    * database operations out of the DAO Context. To establish a JDBC connection
13    * for unit tests call the constructor: <br>
14    * DatabaseActions(boolean activateTestMode);
15    *
16    * @author elmar.dott@gmail.com
17    * @version 2.0
18    * @since 1.0
19    */
20    @API(status = STABLE, since = "1.0", consumers = "JdbcActions")
21    @Component
 
22    public interface DatabaseActions {
23   
24    /**
25    * Identifier for the given feature.
26    */
27    @API(status = STABLE, since = "1.2")
28    String FEATURE_ID = "CM-08";
29   
30    /**
31    * Establish an JDBC connection. If the propertyFile parameter is empty,
32    * then the method load by default the configuration from the classpath. The
33    * path to the external property file have to be relative to the execution
34    * path.
35    *
36    * @param propertyFile as String
37    * @return true on success
38    */
39    @API(status = STABLE, since = "1.0")
40    boolean connect(String propertyFile);
41   
42    /**
43    * Execute a plain SQL query and get the ResultSet. If there exist multiple
44    * SELECT statements, then the ResultSet contains only the rusultSet of the
45    * last SELECT statement.
46    *
47    * @param sql as String
48    * @return result as ResultSet
49    * @throws java.sql.SQLException
50    */
51    @API(status = STABLE, since = "3.0")
52    ResultSet executeQuery(String sql) throws SQLException;
53   
54    /**
55    * Load an SQL file from the classpath and execute the script.
56    * <b>Attention:</b> This function should be used to populate a database and
57    * so on. It is not designed to handle multiple ResultSets by using SELECT.
58    * If multiple SELECT statements appears in an SQL file, then only the
59    * ResultSet of the last SELECT statement will be available. <br>
60    * Internal call this function for each single SQL statement the
61    * executeQuery() method.
62    *
63    * @param sqlFile as String
64    * @return true on success
65    */
66    @API(status = STABLE, since = "1.0")
67    boolean executeSqlFromClasspath(String sqlFile);
68   
69    /**
70    * Count the size of a ResultSet.
71    *
72    * @param results as ResultSet
73    * @return count the results
74    * @throws java.sql.SQLException
75    */
76    @API(status = STABLE, since = "3.0")
77    int countResultSets(ResultSet results) throws SQLException;
78   
79    /**
80    * Return a object with all JDBC connection meta date.
81    *
82    * @return JdbcConnection as Object
83    * @throws java.sql.SQLException
84    */
85    @API(status = STABLE, since = "3.0")
86    JdbcConnection getJdbcMetaData() throws SQLException;
87    }