Revision 18370 trunk/extensions/extOracleSpatial/src/es/prodevelop/cit/gvsig/fmap/drivers/jdbc/oracle/OracleSpatialWriter.java
OracleSpatialWriter.java | ||
---|---|---|
145 | 145 |
return true; |
146 | 146 |
} |
147 | 147 |
} |
148 |
|
|
149 |
public static boolean createEmptyTable( |
|
150 |
DBLayerDefinition lyr_def, |
|
151 |
IConnection the_conn, |
|
152 |
Rectangle2D rect) { |
|
153 |
|
|
154 |
String srid_epsg = lyr_def.getSRID_EPSG(); |
|
155 |
boolean with_srid = true; |
|
156 |
String _ora_srid = "NULL"; |
|
157 |
|
|
158 |
try { |
|
159 |
_ora_srid = OracleSpatialDriver.epsgSridToOracleSrid(srid_epsg); |
|
160 |
} catch (Exception e1) { |
|
161 |
logger.error("Unknown EPSG code: " + srid_epsg); |
|
162 |
with_srid = false; |
|
163 |
} |
|
148 | 164 |
|
165 |
String _sql_rem_meta = OracleSpatialDriver.getRemoveMetadataSql(lyr_def); |
|
166 |
String _sql_drop = OracleSpatialDriver.getDropTableSql(lyr_def); |
|
167 |
String _sql_creation = OracleSpatialDriver.getTableCreationSql(lyr_def); |
|
168 |
String _sql_index = OracleSpatialDriver.getIndexCreationSql(lyr_def); |
|
169 |
|
|
170 |
String _sql_meta = OracleSpatialDriver.getMetadataUpdateSql( |
|
171 |
lyr_def.getUser(), |
|
172 |
lyr_def.getTableName(), |
|
173 |
_ora_srid, rect, 2, with_srid); |
|
174 |
|
|
175 |
boolean removed = true; |
|
176 |
|
|
177 |
try { |
|
178 |
java.sql.PreparedStatement ps = |
|
179 |
((ConnectionJDBC) the_conn).getConnection().prepareStatement(_sql_drop); |
|
180 |
ps.execute(); |
|
181 |
ps.close(); |
|
182 |
} |
|
183 |
catch (SQLException ex) { |
|
184 |
logger.info("Table did not exist: " + lyr_def.getTableName()); |
|
185 |
removed = false; |
|
186 |
} |
|
187 |
|
|
188 |
if (removed) { |
|
189 |
logger.info("Table existed and was deleted: " + lyr_def.getTableName()); |
|
190 |
} |
|
191 |
|
|
192 |
try { |
|
193 |
java.sql.PreparedStatement ps = ((ConnectionJDBC) the_conn).getConnection().prepareStatement(_sql_creation); |
|
194 |
ps.execute(); |
|
195 |
ps.close(); |
|
196 |
} |
|
197 |
catch (SQLException ex) { |
|
198 |
logger.error("Error while executing SQL for table creation: " + |
|
199 |
ex.getMessage(), ex); |
|
200 |
return false; |
|
201 |
} |
|
202 |
|
|
203 |
try { |
|
204 |
java.sql.PreparedStatement ps = ((ConnectionJDBC)the_conn).getConnection().prepareStatement(_sql_rem_meta); |
|
205 |
ps.execute(); |
|
206 |
ps.close(); |
|
207 |
} |
|
208 |
catch (SQLException ex) { |
|
209 |
logger.error("Error while executing SQL for metadata removal: " + |
|
210 |
ex.getMessage(), ex); |
|
211 |
} |
|
212 |
|
|
213 |
try { |
|
214 |
java.sql.PreparedStatement ps = ((ConnectionJDBC)the_conn).getConnection().prepareStatement(_sql_meta); |
|
215 |
ps.execute(); |
|
216 |
ps.close(); |
|
217 |
} |
|
218 |
catch (SQLException ex) { |
|
219 |
logger.error( |
|
220 |
"Error while executing SQL for metadata insertion: " + |
|
221 |
ex.getMessage(), ex); |
|
222 |
return false; |
|
223 |
} |
|
224 |
|
|
225 |
try { |
|
226 |
java.sql.PreparedStatement ps = ((ConnectionJDBC)the_conn).getConnection().prepareStatement(_sql_index); |
|
227 |
ps.execute(); |
|
228 |
ps.close(); |
|
229 |
} |
|
230 |
catch (SQLException ex) { |
|
231 |
logger.error("Error while executing SQL for index creation: " + |
|
232 |
ex.getMessage(), ex); |
|
233 |
return false; |
|
234 |
} |
|
235 |
|
|
236 |
return true; |
|
237 |
} |
|
238 |
|
|
149 | 239 |
public void preProcess() throws StartWriterVisitorException { |
150 | 240 |
|
151 | 241 |
IConnection conn = ((DBLayerDefinition) tableDef).getConnection(); |
Also available in: Unified diff