• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

torand / FasterSQL / 17071815266

19 Aug 2025 01:54PM UTC coverage: 68.2%. Remained the same
17071815266

push

github

torand
refactor: mitigate cyclic deps

299 of 598 branches covered (50.0%)

Branch coverage included in aggregate %.

19 of 23 new or added lines in 2 files covered. (82.61%)

1629 of 2229 relevant lines covered (73.08%)

3.98 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.0
/src/main/java/io/github/torand/fastersql/dialect/DialectResolver.java
1
package io.github.torand.fastersql.dialect;
2

3
import io.github.torand.fastersql.statement.FasterSQLException;
4

5
import java.sql.Connection;
6
import java.sql.SQLException;
7

8
/**
9
 * Resolves SQL dialect based on an open JDBC {@link Connection}.
10
 */
11
public final class DialectResolver {
12
    private DialectResolver() {}
13

14
    /**
15
     * Creates the {@link Dialect} instance corresponding to database vendor associated with specified connection.
16
     * @param connection the connection.
17
     * @return the {@link Dialect} instance.
18
     */
19
    public static Dialect fromConnection(Connection connection) {
20
        try {
21
            String productName = connection.getMetaData().getDatabaseProductName().toLowerCase();
5✔
22

23
            if (productName.contains("h2")) {
4✔
24
                return new H2Dialect().withCustomizations(connection);
6✔
25
            } else if (productName.contains("mysql")) {
4✔
26
                return new MySqlDialect();
4✔
27
            } else if (productName.contains("mariadb")) {
4✔
28
                return new MariaDbDialect();
4✔
29
            } else if (productName.contains("postgresql")) {
4✔
30
                return new PostgreSqlDialect();
4✔
31
            } else if (productName.contains("oracle")) {
4✔
32
                return new OracleDialect();
4✔
33
            } else if (productName.contains("sql server")) {
4✔
34
                return new SqlServerDialect();
4✔
35
            } else if (productName.contains("access")) {
4✔
36
                return new AccessDialect();
4✔
37
            } else if (productName.contains("sqlite")) {
4✔
38
                return new SqliteDialect();
4✔
39
            } else if (productName.contains("hsql")) {
4!
40
                return new HsqldbDialect();
4✔
41
            } else {
NEW
42
                throw new UnsupportedOperationException("Database with product name " + productName + " not supported");
×
43
            }
NEW
44
        } catch (SQLException e) {
×
NEW
45
            throw new FasterSQLException("Failed to detect SQL dialect from connection metadata", e);
×
46
        }
47
    }
48
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc