1717 */
1818package xdev .db .db2i .jdbc ;
1919
20- /*-
21- * #%L
22- * DB2i
23- * %%
24- * Copyright (C) 2003 - 2023 XDEV Software
25- * %%
26- * This program is free software: you can redistribute it and/or modify
27- * it under the terms of the GNU Lesser General Public License as
28- * published by the Free Software Foundation, either version 3 of the
29- * License, or (at your option) any later version.
30- *
31- * This program is distributed in the hope that it will be useful,
32- * but WITHOUT ANY WARRANTY; without even the implied warranty of
33- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34- * GNU General Lesser Public License for more details.
35- *
36- * You should have received a copy of the GNU General Lesser Public
37- * License along with this program. If not, see
38- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
39- * #L%
40- */
41-
42-
43- import xdev .db .DBException ;
44- import xdev .db .jdbc .JDBCConnection ;
45-
4620import java .sql .Connection ;
4721import java .sql .ResultSet ;
4822import java .sql .SQLException ;
4923import java .sql .Statement ;
5024import java .util .Map ;
25+
26+ import xdev .db .DBException ;
27+ import xdev .db .jdbc .JDBCConnection ;
5128public class DB2iJDBCConnection extends JDBCConnection <DB2iJDBCDataSource , DB2iDbms >
5229{
53- public DB2iJDBCConnection (DB2iJDBCDataSource dataSource )
30+ public DB2iJDBCConnection (final DB2iJDBCDataSource dataSource )
5431 {
5532 super (dataSource );
5633 }
@@ -59,71 +36,70 @@ public DB2iJDBCConnection(DB2iJDBCDataSource dataSource)
5936 @ Override
6037 protected Connection establishConnection () throws DBException
6138 {
62- Connection con = super .establishConnection ();
39+ final Connection con = super .establishConnection ();
6340
6441 try
6542 {
66- String schema = dataSource .getSchema ();
67- if (schema != null && schema .length () > 0 && !schema .equals (dataSource .getUserName ()))
43+ final String schema = this . dataSource .getSchema ();
44+ if (schema != null && schema .length () > 0 && !schema .equals (this . dataSource .getUserName ()))
6845 {
6946 con .createStatement ().execute ("SET SCHEMA " + schema ); //$NON-NLS-1$
7047 }
7148 }
72- catch (SQLException e )
49+ catch (final SQLException e )
7350 {
74- throw new DBException (dataSource ,e );
51+ throw new DBException (this . dataSource , e );
7552 }
7653
7754 return con ;
7855 }
7956
80-
8157 @ Override
82- public int getQueryRowCount (String select ) throws DBException
58+ public int getQueryRowCount (final String select ) throws DBException
8359 {
84- StringBuilder sb = new StringBuilder ();
60+ final StringBuilder sb = new StringBuilder ();
8561 sb .append ("SELECT COUNT(*) FROM (" ); //$NON-NLS-1$
8662 sb .append (select );
8763 sb .append (")" ); //$NON-NLS-1$
8864
8965 try
9066 {
91- ResultSet result = queryJDBC (sb .toString ());
67+ final ResultSet result = this . queryJDBC (sb .toString ());
9268 try
9369 {
9470 result .next ();
95- int rowCount = result .getInt (1 );
71+ final int rowCount = result .getInt (1 );
9672 return rowCount ;
9773 }
9874 finally
9975 {
10076 result .close ();
10177 }
10278 }
103- catch (DBException e )
79+ catch (final DBException e )
10480 {
10581 throw e ;
10682 }
107- catch (Exception e )
83+ catch (final Exception e )
10884 {
109- throw new DBException (dataSource ,e );
85+ throw new DBException (this . dataSource , e );
11086 }
11187 }
11288
113-
11489 @ Override
115- public void createTable (String tableName , String primaryKey , Map <String , String > columnMap ,
116- boolean isAutoIncrement , Map <String , String > foreignKeys ) throws Exception
90+ public void createTable (
91+ final String tableName , final String primaryKey , final Map <String , String > columnMap ,
92+ final boolean isAutoIncrement , final Map <String , String > foreignKeys ) throws Exception
11793 {
118- Connection connection = super .getConnection ();
119- Statement statement = connection .createStatement ();
94+ final Connection connection = super .getConnection ();
95+ final Statement statement = connection .createStatement ();
12096 try
12197 {
122- if (!checkIfTableExists (connection .createStatement (),tableName ))
98+ if (!this . checkIfTableExists (connection .createStatement (), tableName ))
12399 {
124100 if (!columnMap .containsKey (primaryKey ))
125101 {
126- columnMap .put (primaryKey ,"INTEGER" ); //$NON-NLS-1$
102+ columnMap .put (primaryKey , "INTEGER" ); //$NON-NLS-1$
127103 }
128104 StringBuffer createStatement = null ;
129105
@@ -142,14 +118,14 @@ public void createTable(String tableName, String primaryKey, Map<String, String>
142118 }
143119
144120 int i = 0 ;
145- for (String keySet : columnMap .keySet ())
121+ for (final String keySet : columnMap .keySet ())
146122 {
147123 if (!keySet .equals (primaryKey ))
148124 {
149125 if (i <= columnMap .size ())
150126 {
151- createStatement .append (keySet + " " + columnMap . get ( keySet ) + "," ); //$NON-NLS-1$ //$NON-NLS-2$
152-
127+ createStatement .append (
128+ keySet + " " + columnMap . get ( keySet ) + "," ); //$NON-NLS-1$ //$NON-NLS-2$
153129 }
154130 else
155131 {
@@ -169,7 +145,7 @@ public void createTable(String tableName, String primaryKey, Map<String, String>
169145 statement .execute (createStatement .toString ());
170146 }
171147 }
172- catch (Exception e )
148+ catch (final Exception e )
173149 {
174150 throw e ;
175151 }
@@ -180,19 +156,19 @@ public void createTable(String tableName, String primaryKey, Map<String, String>
180156 }
181157 }
182158
183-
184- private boolean checkIfTableExists (Statement statement , String tableName ) throws Exception
159+ private boolean checkIfTableExists (final Statement statement , final String tableName ) throws Exception
185160 {
186161
187- String sql = "SELECT NAME FROM SYSIBM.SYSTABLES WHERE NAME='" + tableName + "'" ; //$NON-NLS-1$ //$NON-NLS-2$
162+ final String sql =
163+ "SELECT NAME FROM SYSIBM.SYSTABLES WHERE NAME='" + tableName + "'" ; //$NON-NLS-1$ //$NON-NLS-2$
188164
189165 ResultSet resultSet = null ;
190166 try
191167 {
192168 statement .execute (sql );
193169 resultSet = statement .getResultSet ();
194170 }
195- catch (Exception e )
171+ catch (final Exception e )
196172 {
197173 if (resultSet != null )
198174 {
0 commit comments