Revision 29091
trunk/extensions/extJDBC/src/com/iver/cit/gvsig/fmap/drivers/jdbc/mysql/MySQLDriver.java | ||
---|---|---|
84 | 84 |
|
85 | 85 |
private MySQLSpatialWriter writer = new MySQLSpatialWriter(); |
86 | 86 |
|
87 |
private static final String[] GEOM_SQL_TYPE_NAMES ={ |
|
88 |
"GEOMETRY", |
|
89 |
"POINT", |
|
90 |
"LINESTRING", |
|
91 |
"POLYGON", |
|
92 |
"MULTIPOINT", |
|
93 |
"MULTILINESTRING", |
|
94 |
"MULTIPOLYGON", |
|
95 |
"GEOMETRYCOLLECTION", |
|
96 |
}; |
|
97 |
|
|
87 | 98 |
/* |
88 | 99 |
* private int fetch_min=-1; private int fetch_max=-1; |
89 | 100 |
*/ |
... | ... | |
484 | 495 |
return clonedLyrDef; |
485 | 496 |
} |
486 | 497 |
|
498 |
|
|
499 |
/** |
|
500 |
* Gets the table's possible geometry fields. By default, all fields can be geometry |
|
501 |
* fields. It should be overwritten by subclasses. |
|
502 |
* |
|
503 |
* @param conn conenction object |
|
504 |
* @param table_name table name |
|
505 |
* @return the table's possible geometry fields |
|
506 |
* @throws SQLException |
|
507 |
*/ |
|
508 |
public String[] getGeometryFieldsCandidates(IConnection conn, String table_name) throws DBException { |
|
509 |
try { |
|
510 |
Statement st = ((ConnectionJDBC)conn).getConnection().createStatement(); |
|
511 |
ResultSet rs = st.executeQuery("select * from " + table_name + " where false"); |
|
512 |
ResultSetMetaData rsmd = rs.getMetaData(); |
|
513 |
ArrayList names = new ArrayList(); |
|
514 |
ResultSetMetaData rsMeta = rs.getMetaData(); |
|
515 |
boolean isGeo; |
|
516 |
for (int i = 0; i < rsMeta.getColumnCount(); i++) { |
|
517 |
isGeo = false; |
|
518 |
System.out.println(rsMeta.getColumnName(i+1)); |
|
519 |
for (int j = 0;j< GEOM_SQL_TYPE_NAMES.length;j++){ |
|
520 |
rsMeta.getColumnType(i+1); |
|
521 |
System.out.println(rsMeta.getColumnTypeName(i+1)); |
|
522 |
if (GEOM_SQL_TYPE_NAMES[j].equalsIgnoreCase(rsMeta.getColumnTypeName(i+1))){ |
|
523 |
isGeo = true; |
|
524 |
break; |
|
525 |
} |
|
526 |
} |
|
527 |
if (isGeo || "UNKNOWN".equalsIgnoreCase(rsMeta.getColumnTypeName(i+1))){ |
|
528 |
names.add(rsMeta.getColumnName(i+1)); |
|
529 |
} |
|
530 |
} |
|
531 |
rsMeta = null; |
|
532 |
rs.close(); st.close(); |
|
533 |
return (String[]) names.toArray(new String[names.size()]); |
|
534 |
} catch (SQLException e) { |
|
535 |
throw new DBException(e); |
|
536 |
} |
|
487 | 537 |
} |
538 |
|
|
539 |
} |
Also available in: Unified diff