Skip to content

Commit

Permalink
add sql exeucutor demo
Browse files Browse the repository at this point in the history
  • Loading branch information
ywy2090 committed Sep 1, 2024
1 parent e97cc4a commit 37a1565
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -250,25 +250,4 @@ public void executeSQL(DBType dbType, DBDataSource dbDataSource, ExecutorCallbac
throw new DatasetException("execute sql Exception, e: " + e.getMessage());
}
}

// TODO:
public static void main(String[] args) throws DatasetException {

DBDataSource dbDataSource = new DBDataSource();
dbDataSource.setSql("select * from t_ucl_c_user_missed_record");
dbDataSource.setDatabase("ppcs_integ");
dbDataSource.setDbIp("127.0.0.1");
dbDataSource.setDbPort(3306);
dbDataSource.setUserName("root");
dbDataSource.setPassword("123456");

SQLExecutor sqlExecutor = new SQLExecutor();
sqlExecutor.executeSQL(
DBType.MYSQL,
dbDataSource,
(fields, rowValues) -> {
System.out.println(fields);
System.out.println(rowValues);
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.webank.wedpr.components.dataset.sqlutils.demo;

import com.webank.wedpr.components.dataset.datasource.DBType;
import com.webank.wedpr.components.dataset.datasource.category.DBDataSource;
import com.webank.wedpr.components.dataset.exception.DatasetException;
import com.webank.wedpr.components.dataset.sqlutils.SQLExecutor;

public class Main {
public static void main(String[] args) throws DatasetException {

String sql = "select * from wedpr_dataset";
String database = "wedpr3";
String host = "127.0.0.1";
int port = 3306;
String user = "root";
String password = "123456";

DBDataSource dbDataSource = new DBDataSource();
dbDataSource.setSql(sql);
dbDataSource.setDatabase(database);
dbDataSource.setDbIp(host);
dbDataSource.setDbPort(port);
dbDataSource.setUserName(user);
dbDataSource.setPassword(password);

SQLExecutor sqlExecutor = new SQLExecutor();
sqlExecutor.executeSQL(
DBType.MYSQL,
dbDataSource,
(fields, rowValues) -> {
System.out.println(fields);
System.out.println(rowValues);
});
}
}

0 comments on commit 37a1565

Please sign in to comment.