// 创建连接参数
Map<String, Object> params = new HashMap<>();
params.put("dbtype", "mysql");
params.put("host", "localhost");
params.put("port", 3306);
params.put("database", "your_database_name"); // 替换为你的数据库名
params.put("user", "your_username"); // 替换为你的数据库用户名
params.put("passwd", "your_password"); // 替换为你的数据库密码
// 连接数据库
DataStore dataStore = DataStoreFinder.getDataStore(params);
JDBCDataStore store = (JDBCDataStore)dataStore ;
Connection interconnection = store.getDataSource().getConnection();
DatabaseMetaData metaData = interconnection.getMetaData();
this.version = metaData.getDatabaseProductVersion();
思路主要还是将数据源转化为普通的数据库Connection