com.strider.datadefender.database.metadata.MySqlMetaData   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
c 1
b 0
f 0
dl 0
loc 28
ccs 0
cts 12
cp 0
rs 10
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getColumnResultSet(DatabaseMetaData,String) 0 3 1
A MySqlMetaData(DbConfig,Connection) 0 2 1
A getPrimaryKeysResultSet(DatabaseMetaData,String) 0 3 1
A MySqlMetaData(DbConfig,Connection,SqlTypeToClass) 0 2 1
A getTableResultSet(DatabaseMetaData) 0 3 1
A getForeignKeysResultSet(DatabaseMetaData,String) 0 3 1
1
/*
2
 * Copyright 2014, Armenak Grigoryan, and individual contributors as indicated
3
 * by the @authors tag. See the copyright.txt in the distribution for a
4
 * full listing of individual contributors.
5
 *
6
 * This is free software; you can redistribute it and/or modify it
7
 * under the terms of the GNU Lesser General Public License as
8
 * published by the Free Software Foundation; either version 2.1 of
9
 * the License, or (at your option) any later version.
10
 *
11
 * This software is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
 * Lesser General Public License for more details.
15
 */
16
package com.strider.datadefender.database.metadata;
17
18
import com.strider.datadefender.DbConfig;
19
import java.sql.Connection;
20
import java.sql.DatabaseMetaData;
21
import java.sql.ResultSet;
22
import java.sql.SQLException;
23
24
/**
25
 * Overridden to omit using schema in some cases, as it's not supported.
26
 * @author armenak
27
 */
28
public class MySqlMetaData extends MetaData {
29
30
    public MySqlMetaData(DbConfig config, Connection connection) {
31
        super(config, connection);
32
    }
33
34
    public MySqlMetaData(DbConfig config, Connection connection, SqlTypeToClass sqlTypeMap) {
35
        super(config, connection, sqlTypeMap);
36
    }
37
38
    @Override
39
    protected ResultSet getTableResultSet(final DatabaseMetaData md) throws SQLException {
40
        return md.getTables(null, null, "%", new String[] { "TABLE" });
41
    }
42
43
    @Override
44
    protected ResultSet getColumnResultSet(final DatabaseMetaData md, final String tableName) throws SQLException {
45
        return md.getColumns(null, null, tableName, null);
46
    }
47
48
    @Override
49
    protected ResultSet getForeignKeysResultSet(final DatabaseMetaData md, final String tableName) throws SQLException {
50
        return md.getImportedKeys(null, null, tableName);
51
    }
52
53
    @Override
54
    protected ResultSet getPrimaryKeysResultSet(final DatabaseMetaData md, final String tableName) throws SQLException {
55
        return md.getPrimaryKeys(null, null, tableName);
56
    }
57
}
58