Skip to content

Commit

Permalink
add sqlite support
Browse files Browse the repository at this point in the history
  • Loading branch information
hdhome committed Aug 22, 2017
1 parent 9dc2d5f commit e1db858
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/main/java/com/zzg/mybatis/generator/model/DbType.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ public enum DbType {
MySQL("com.mysql.jdbc.Driver", "jdbc:mysql://%s:%s/%s?useUnicode=true&useSSL=false&characterEncoding=%s", "mysql-connector-java-5.1.38.jar"),
Oracle("oracle.jdbc.driver.OracleDriver", "jdbc:oracle:thin:@%s:%s:%s", "ojdbc14.jar"),
PostgreSQL("org.postgresql.Driver", "jdbc:postgresql://%s:%s/%s", "postgresql-9.4.1209.jar"),
SQL_Server("com.microsoft.sqlserver.jdbc.SQLServerDriver", "jdbc:sqlserver://%s:%s;databaseName=%s", "sqljdbc4-4.0.jar");
SQL_Server("com.microsoft.sqlserver.jdbc.SQLServerDriver", "jdbc:sqlserver://%s:%s;databaseName=%s", "sqljdbc4-4.0.jar"),
Sqlite("org.sqlite.JDBC", "jdbc:sqlite:%s", "sqlite-jdbc-3.19.3.jar");

private final String driverClass;
private final String connectionUrlPattern;
Expand Down
9 changes: 8 additions & 1 deletion src/main/java/com/zzg/mybatis/generator/util/DbUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,14 @@ public static List<String> getTableNames(DatabaseConfig config) throws Exception
}
} else if (DbType.valueOf(config.getDbType()) == DbType.Oracle){
rs = md.getTables(null, config.getUsername().toUpperCase(), null, new String[] {"TABLE", "VIEW"});
} else {
} else if (DbType.valueOf(config.getDbType())==DbType.Sqlite){
String sql = "Select name from sqlite_master;";
rs = connection.createStatement().executeQuery(sql);
while (rs.next()) {
tables.add(rs.getString("name"));
}
}
else {
// rs = md.getTables(null, config.getUsername().toUpperCase(), null, null);
rs = md.getTables(null, "%", "%", new String[] {"TABLE", "VIEW"}); //针对 postgresql 的左侧数据表显示
}
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/fxml/newConnection.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<String fx:value="Oracle" />
<String fx:value="PostgreSQL" />
<String fx:value="SQL_Server" />
<String fx:value="Sqlite" />
</FXCollections>
</items>
</ChoiceBox>
Expand Down
Binary file added src/main/resources/lib/sqlite-jdbc-3.19.3.jar
Binary file not shown.

0 comments on commit e1db858

Please sign in to comment.