Revision 337563aa
Added by Andreas Müller over 6 years ago
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/ICdmDataSource.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Copyright (C) 2007 EDIT |
3 |
* European Distributed Institute of Taxonomy
|
|
3 |
* European Distributed Institute of Taxonomy |
|
4 | 4 |
* http://www.e-taxonomy.eu |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
... | ... | |
28 | 28 |
* @return BeanDefinition |
29 | 29 |
*/ |
30 | 30 |
public BeanDefinition getDatasourceBean(); |
31 |
|
|
31 |
|
|
32 | 32 |
/** |
33 | 33 |
* @param hbm2dll |
34 | 34 |
* @return BeanDefinition |
35 | 35 |
*/ |
36 | 36 |
public BeanDefinition getHibernatePropertiesBean(DbSchemaValidation hbm2dll); |
37 |
|
|
37 |
|
|
38 | 38 |
/** |
39 | 39 |
* @param hbm2dll |
40 | 40 |
* @param showSql |
... | ... | |
45 | 45 |
public BeanDefinition getHibernatePropertiesBean(DbSchemaValidation hbm2dll, Boolean showSql, Boolean formatSql, Boolean registerSearchListener, Class<? extends RegionFactory> cacheProviderClass); |
46 | 46 |
|
47 | 47 |
|
48 |
|
|
49 | 48 |
/** |
50 | 49 |
* @return |
51 | 50 |
*/ |
... | ... | |
55 | 54 |
* @return |
56 | 55 |
*/ |
57 | 56 |
public H2Mode getMode(); |
58 |
|
|
57 |
|
|
59 | 58 |
public String getUsername(); |
60 |
|
|
59 |
|
|
61 | 60 |
public String getPassword(); |
62 |
|
|
61 |
|
|
63 | 62 |
public String getDatabase(); |
64 |
|
|
63 |
|
|
65 | 64 |
public void setMode(H2Mode h2Mode); |
66 |
|
|
65 |
|
|
67 | 66 |
public void setUsername(String username); |
68 |
|
|
67 |
|
|
69 | 68 |
public void setPassword(String password); |
70 |
|
|
69 |
|
|
71 | 70 |
public void setDatabase(String database); |
72 |
|
|
73 |
|
|
71 |
|
|
72 |
|
|
74 | 73 |
/** |
75 |
* Returns the database type of the data source.
|
|
76 |
* @return the database type of the data source.
|
|
74 |
* Returns the database type of the data source. |
|
75 |
* @return the database type of the data source. |
|
77 | 76 |
* <code>null</code> if the bean or the driver class property does not exist or the driver class is unknown. |
78 | 77 |
*/ |
79 | 78 |
public DatabaseTypeEnum getDatabaseType(); |
80 | 79 |
/** |
81 | 80 |
* Tests, if a database connection can be established. |
82 | 81 |
* @return true if test was successful, false otherwise |
83 |
* @throws ClassNotFoundException
|
|
84 |
* @throws SQLException
|
|
85 |
* @throws Exception
|
|
82 |
* @throws ClassNotFoundException |
|
83 |
* @throws SQLException |
|
84 |
* @throws Exception |
|
86 | 85 |
*/ |
87 | 86 |
public boolean testConnection() throws ClassNotFoundException, SQLException; |
88 |
|
|
87 |
|
|
89 | 88 |
|
90 | 89 |
/** |
91 | 90 |
* Executes a query and returns the ResultSet. |
92 | 91 |
* @return ResultSet for the query. |
93 |
* @throws SQLException
|
|
92 |
* @throws SQLException |
|
94 | 93 |
*/ |
95 | 94 |
public ResultSet executeQuery (String query) throws SQLException; |
96 |
|
|
95 |
|
|
97 | 96 |
/** |
98 | 97 |
* Executes an update |
99 | 98 |
* @return return code |
100 | 99 |
*/ |
101 | 100 |
public int executeUpdate (String sqlUpdate) throws SQLException; |
102 |
|
|
101 |
|
|
103 | 102 |
/** |
104 | 103 |
* Starts a transaction for the given datasource. |
105 | 104 |
*/ |
106 | 105 |
public void startTransaction(); |
107 |
|
|
106 |
|
|
108 | 107 |
/** |
109 | 108 |
* Commits the transaction for the given datasource. |
110 | 109 |
* @return |
111 |
* @throws SQLException
|
|
110 |
* @throws SQLException |
|
112 | 111 |
*/ |
113 | 112 |
public void commitTransaction() throws SQLException; |
114 |
|
|
113 |
|
|
115 | 114 |
/** |
116 | 115 |
* Rolls the connection back. |
117 |
* @throws SQLException
|
|
116 |
* @throws SQLException |
|
118 | 117 |
*/ |
119 | 118 |
public void rollback() throws SQLException; |
120 | 119 |
|
... | ... | |
123 | 122 |
* Returns the first value of the first row of a result set.<BR> |
124 | 123 |
* If no row exists in the result set |
125 | 124 |
* <code>null</code> is returned. |
126 |
*
|
|
125 |
* |
|
127 | 126 |
* <strong>Caution</strong> This method opens a connection on first use. Subsequent calls will use the same connection. |
128 | 127 |
* Please close the connection when not needed anymore with {@link ICdmDataSource#closeOpenConnections()} |
129 |
*
|
|
128 |
* |
|
130 | 129 |
* @param query |
131 | 130 |
* @return |
132 | 131 |
* @throws SQLException |
133 | 132 |
*/ |
134 |
public Object getSingleValue(String query) throws SQLException;
|
|
135 |
|
|
133 |
public Object getSingleValue(String query) throws SQLException; |
|
134 |
|
|
136 | 135 |
/** |
137 | 136 |
* Returns {@link DatabaseMetaData} for <code>this</code> datasource. |
138 |
*
|
|
137 |
* |
|
139 | 138 |
* <br> |
140 | 139 |
* <br> |
141 | 140 |
* <strong>Caution</strong> This method opens a connection that should be closed |
142 | 141 |
* with {@link #closeOpenConnections()} |
143 |
*
|
|
142 |
* |
|
144 | 143 |
* @return |
145 | 144 |
*/ |
146 | 145 |
public DatabaseMetaData getMetaData(); |
Also available in: Unified diff
cleanup