use of com.varsql.core.db.valueobject.SqlStatementInfo in project varsql by varsqlinfo.
the class FileImportExportServiceImpl method jsonImport.
private SQLExecuteResult jsonImport(FileInfoEntity fileInfo, String conuid) throws SQLException {
SqlStatementInfo ssi = new SqlStatementInfo();
ssi.setConuid(conuid);
ssi.setExportType(VarsqlFileType.JSON.name());
ssi.addCustom(FileImportExecutor.IMPORT_FILE_PARAM_NAME, FileServiceUtils.getPath(fileInfo.getFilePath()).toUri());
SQLExecuteResult ser = new FileImportExecutor().execute(ssi);
return ser;
}
use of com.varsql.core.db.valueobject.SqlStatementInfo in project varsql by varsqlinfo.
the class BaseExecutorTest method testUpdate.
// @Test
// @Ignore
void testUpdate() {
ConnectionInfo connInfo = getBaseConnection();
try {
DatabaseInfo di = getDatabaseInfo(connInfo);
SqlStatementInfo sqi = new SqlStatementInfo();
sqi.setSchema("PUBLIC");
sqi.setConuid(connInfo.getConnid(), TEST_CON_UID, di);
SQLExecutor baseExecutor = new SqlUpdateExecutor();
sqi.setSqlParam("{}");
String insertQuery = getResourceContent("/db/importdata/insertdata.sql");
sqi.setSql(insertQuery);
SQLExecuteResult ser = baseExecutor.execute(sqi, new AbstractSQLExecutorHandler() {
@Override
public boolean handle(SQLHandlerParameter handleParam) {
return true;
}
});
System.out.println("testUpdate ser.getTotalCount(): " + ser.getTotalCount());
System.out.println("testUpdate ser.getResult(): " + ser.getResult());
} catch (Exception e) {
e.printStackTrace();
}
}
use of com.varsql.core.db.valueobject.SqlStatementInfo in project varsql by varsqlinfo.
the class BaseExecutorTest method testSelect.
@Test
// @Ignore
void testSelect() {
ConnectionInfo connInfo = getBaseConnection();
try {
DatabaseInfo di = getDatabaseInfo(connInfo);
SqlStatementInfo sqi = new SqlStatementInfo();
sqi.setSchema("PUBLIC");
sqi.setConuid(connInfo.getConnid(), TEST_CON_UID, di);
SQLExecutor baseExecutor = new SelectExecutor();
sqi.setSqlParam("{}");
sqi.setSql("select * from test2222");
SQLWriter writer = new SQLWriter(new FileOutputStream(new File("c:/zzz/exportInsertQuery.sql")), DBType.getDBType(sqi.getDbType()), "test2222");
AbstractSQLExecutorHandler handler = new AbstractSQLExecutorHandler() {
private boolean firstFlag = true;
@Override
public boolean handle(SQLHandlerParameter handleParam) {
if (firstFlag) {
writer.setColumnInfos(handleParam.getColumnInfoList());
firstFlag = false;
}
try {
writer.addRow(handleParam.getRowObject());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return true;
}
};
SQLExecuteResult ser = baseExecutor.execute(sqi, handler);
writer.write();
System.out.println("testUpdate ser.getTotalCount(): " + ser.getTotalCount());
System.out.println("testSelect ser.getResult(): " + ser.getResult());
} catch (Exception e) {
e.printStackTrace();
}
}
use of com.varsql.core.db.valueobject.SqlStatementInfo in project varsql by varsqlinfo.
the class FileImportExportServiceImpl method sqlImport.
/**
* @method : sqlImport
* @desc : sql import
* @author : ytkim
* @date : 2021. 5. 23.
* @param fileInfo
* @param conuid
* @return
* @throws IOException
* @throws SQLException
*/
private SQLExecuteResult sqlImport(FileInfoEntity fileInfo, String conuid) throws IOException, SQLException {
SqlStatementInfo ssi = new SqlStatementInfo();
ssi.setConuid(conuid);
ssi.setSqlParam("{}");
String insertQuery = FileUtils.readFileToString(FileServiceUtils.getFileInfoToFile(fileInfo));
ssi.setSql(insertQuery);
SQLExecuteResult ser = new SqlUpdateExecutor().execute(ssi, new AbstractSQLExecutorHandler() {
@Override
public boolean handle(SQLHandlerParameter handleParam) {
return true;
}
});
return ser;
}
use of com.varsql.core.db.valueobject.SqlStatementInfo in project varsql by varsqlinfo.
the class FileImportExportServiceImpl method xmlImport.
private SQLExecuteResult xmlImport(FileInfoEntity fileInfo, String conuid) throws SQLException {
SqlStatementInfo ssi = new SqlStatementInfo();
ssi.setConuid(conuid);
ssi.setExportType(VarsqlFileType.XML.name());
ssi.addCustom(FileImportExecutor.IMPORT_FILE_PARAM_NAME, FileServiceUtils.getPath(fileInfo.getFilePath()).toUri());
SQLExecuteResult ser = new FileImportExecutor().execute(ssi);
return ser;
}
Aggregations