Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Error "Table "DBF_INDEX" already exists" #1299

Merged
merged 1 commit into from
Mar 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ Occam Labs UG (haftungsbeschränkt)

/**
* Copies the dbf contents into the h2 db.
*
*
* @author <a href="mailto:schmitz@occamlabs.de">Andreas Schmitz</a>
* @author last edited by: $Author: stranger $
*
*
* @version $Revision: $, $Date: $
*/
class DbfIndexImporter {
Expand All @@ -86,7 +86,7 @@ class DbfIndexImporter {

private Pair<ArrayList<Pair<float[], Long>>, Boolean> envelopes;

private ArrayList<String> fields = new ArrayList<String>();
private ArrayList<String> fields = new ArrayList<>();

private List<Mapping> mappings;

Expand All @@ -111,7 +111,7 @@ private void createTable( StringBuilder sb ) {
private Map<String, Mapping> createMappingMap( List<Mapping> mappings ) {
Map<String, Mapping> fieldMap = null;
if ( mappings != null ) {
fieldMap = new HashMap<String, Mapping>();
fieldMap = new HashMap<>();
for ( Mapping m : mappings ) {
if ( m.propname != null ) {
fieldMap.put( m.propname, m );
Expand Down Expand Up @@ -159,8 +159,7 @@ private void appendFields( StringBuilder create ) {
create.append( ")" );
}

private String createInsertStatement( Map<SimplePropertyType, Property> entry )
throws IOException {
private String createInsertStatement( Map<SimplePropertyType, Property> entry ) {
StringBuilder sb = new StringBuilder();
StringBuilder qms = new StringBuilder();
sb.setLength( 0 );
Expand Down Expand Up @@ -304,7 +303,7 @@ ConnectionProvider createIndex()

connProvider = new LegacyConnectionProvider( "jdbc:h2:" + dbfile, "SA", "", false, null );

if ( new File( dbfile.toString() + ".h2.db" ).exists() ) {
if ( new File( dbfile.toString() + ".mv.db" ).exists() ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file naming strategy has been changed at h2.
This change leads to the fact that the detection of whether the table already exists fails because currently the existence of the table is assumed to be the same as the existence of the file.

// TODO proper check for database consistency
return connProvider;
}
Expand Down