org.springframework.boot
spring-boot-starter-parent
2.3.2.RELEASE
org.springframework.boot
spring-boot-starter-web
junit
junit
test
org.springframework.boot
spring-boot-starter-test
com.vaadin.external.google
android-json
test
org.projectlombok
lombok
mysql
mysql-connector-java
com.scudata.esproc
esproc
20220601
org.hsqldb
hsqldb
2.2.8
com.ibm.icu
icu4j
60.3
org.lucee
jdom
1.1.3
com.alibaba
druid-spring-boot-starter
1.1.10
org.apache.poi
poi
5.2.2
org.apache.xmlbeans
xmlbeans
5.1.0
org.springframework.boot
spring-boot-maven-plugin
2.0.6.RELEASE
SPL无配置文件版
这个版本不依赖raqsoftConfig.xml配置文件,数据库需要我们手动自己添加进去
application.yml
server:
port: 9546
spring:
datasource:
ds1:
driverclassName: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://192.168.118.129:3306/voidme?useCursorFetch=true&useSSL=false
username: root
password: root
dbType: MYSQL
ds2:
driverclassName: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://192.168.118.129:3306/sso?useCursorFetch=true&useSSL=false
username: root
password: root
dbType: MYSQL
JdbcConfig
@Configuration
public class JdbcConfig {
@Bean("local_mysql_1")
@ConfigurationProperties("spring.datasource.ds1")
public DataSource datasourceMysql1() {
return DruidDataSourceBuilder.create().build();
}
@Bean("local_mysql_2")
@ConfigurationProperties("spring.datasource.ds2")
public DataSource datasourceMysql2() {
return DruidDataSourceBuilder.create().build();
}
}
AppInitListener
@Component
public class AppInitListener extends ApplicationObjectSupport implements ApplicationRunner {
@Override
public void run(ApplicationArguments args) throws Exception {
Map beansOfType = getApplicationContext().getBeansOfType(DataSource.class);
for (Map.Entry stringDataSourceEntry : beansOfType.entrySet()) {
DruidDataSource value = (DruidDataSource)stringDataSourceEntry.getValue();
int dbType = DBTypes.getDBType(value.getDbType());
SpringDBSessionFactory.create(stringDataSourceEntry.getKey(), dbType);
}
}
}
SplAppliction
@SpringBootApplication(exclude={DataSourceAutoConfiguration.class, DataSourceTransactionManagerAutoConfiguration.class, })
@ComponentScan({"com.scudata.*","com.splparer.*"})
public class SplAppliction {
public static void main(String[] args) {
SpringApplication.run(SplAppliction.class, args);
}
}
SplTest
@RunWith(SpringRunner.class)
@SpringBootTest(classes = SplAppliction.class, webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
public class SplTest {
@SneakyThrows
@Test
public void contextLoads() {
// FileInputStream fileInputStream=new FileInputStream(new File("C:\Users\huanmin\Desktop\spl\p.spl"));
// PgmCellSet pgmCellSet = AppUtil.readSPL(fileInputStream); //文本文件
// PgmCellSet pgmCellSet = AppUtil.readSPL("C:\Users\huanmin\Desktop\spl\p.spl"); //文本文件
PgmCellSet pgmCellSet = AppUtil.readCellSet("C:\Users\huanmin\Desktop\spl\p.dfx"); //dfx, sqlx 二进制文件
Context context = new Context(); //上下文,参数..设置
pgmCellSet.setContext(context);
Object execute = pgmCellSet.execute();
System.out.println(execute);
}
}
p.splx
结果如下:
这个版本支持的功能比较全,直接调用SPL驱动,需要搭配raqsoftConfig.xml配置文件进行
raqsoftConfig.xml 文件可在本地windows客户端中-选项-环境里自行配置配置好后,就会将内容同步到本地安装目录下esProcconfigraqsoftConfig.xml里 更全配置信息
UTF-8 C:UsershuanminDesktopspl yyyy-MM-dd HH:mm:ss yyyy-MM-dd HH:mm:ss resources/temp 65536 0 1048576 nan,null,n/a INFO
application.yml
server:
port: 9546
spring:
datasource:
driverclassName: com.esproc.jdbc.InternalDriver
url: jdbc:esproc:local://
username: root
password: root
minIdle: 5
maxActive: 100
initialSize: 10
JdbcConfig
@Configuration
public class JdbcConfig {
@Bean
@ConfigurationProperties("spring.datasource")
public DataSource datasource() {
return DruidDataSourceBuilder.create().build();
}
}
SplController
@RestController
@RequestMapping("/spl")
public class SplController {
@Autowired
private SplServiceImpl service;
@GetMapping("")
public void execute() {
service.contextLoads();
}
}
SplService
public interface SplService {
public void contextLoads() ;
}
SplServiceImpl
@Component
public class SplServiceImpl implements SplService {
@Autowired
private DataSource dataSource;
@SneakyThrows
@Override
public void contextLoads() {
long l = System.currentTimeMillis();
//获得数据库连接
Connection connection = dataSource.getConnection();
CallableStatement st = connection.prepareCall("call p()");
//执行存储过程
st.execute();
//获取结果集
ResultSet rs = st.getResultSet();
SplUtil.show(rs);
connection.close();
long l1 = System.currentTimeMillis();
System.out.println("======================:"+String.valueOf(l1-l));
}
}
SplUtil
public class SplUtil {
//显示表格值内容
public static void show( ResultSet rs) throws SQLException {
//简单处理结果集,将结果集中的字段名与数据输出
ResultSetMetaData rsmd = rs.getMetaData();
int colCount = rsmd.getColumnCount();
for ( int c = 1; c <= colCount;c++) {
String title = rsmd.getColumnName(c);
if( c > 1 ) {
System.out.print("t");
}
else {
System.out.print("n");
}
System.out.print(title);
}
while (rs.next()) {
for(int c = 1; c<= colCount; c++) {
if ( c > 1 ) {
System.out.print("t");
}
else {
System.out.print("n");
}
Object o = rs.getObject(c);
System.out.print(o);
}
}
System.out.println();
}
}
SplAppliction
@SpringBootApplication(exclude={DataSourceAutoConfiguration.class, DataSourceTransactionManagerAutoConfiguration.class, })
@ComponentScan({"com.scudata.*","com.spl.*"})
public class SplAppliction {
public static void main(String[] args) {
SpringApplication.run(SplAppliction.class, args);
}
}
注意
- java调用SPL,网格中的代码都会被执行一遍, 但是return只会获取第一个
- 在spl中通过connect进行使用数据库连接,使用完毕后就要关闭,否则就会一直占用连接 ,当然还可以connect@x 方式来调用
- java 调用SPL第一次会加载类库等, 稍微有点慢大概需要300毫秒, 之后就快了也就几毫秒



