连接mysql
Class.forName("com.mysql.jdbc.Driver");
Connection connection = DriverManager.getConnection(url, user, password);
PreparedStatement statement = mysqlConnect.prepareStatement(executeSql);
int executeResult = statement.executeUpdate();
连接mongoDB
引入依赖:
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>3.12.10</version>
</dependency>
MongoClientURI uri = new MongoClientURI(connectUrl);
MongoClient client = new MongoClient(uri);
MongoDatabase mongoConnect = client.getDatabase(databaseModel.getDatabaseName());
MongoCollection<Document> collection = mongoConnect.getCollection(tableModel.getTableName());
DeleteResult result = collection.deleteMany(query);
|