「java如何并行查询」java并行处理list

博主:adminadmin 2023-03-19 14:58:08 401

本篇文章给大家谈谈java如何并行查询,以及java并行处理list对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。

本文目录一览:

分库的数据用java怎么并行查询

如果使用java多线程查询,必须使用CyclicBarrier,等待所有结果都查询完成合并结果集,或者使用dblink,然后HINT方式使用并行Parallell,利用数据的并行技术进行查询

如何使用java对mysql数据库中的一行数据查询

1、登陆SYS用户,执行以下代码

begin

Dbms_Java.Grant_Permission('PSIID','java.io.FilePermission', 'ALL FILE','read ,write, execute, delete');

Dbms_java.grant_permission('PSIID', 'SYS:java.io.FilePermission', 'ALL FILES','read ,write, execute, delete');

Dbms_Java.Grant_Permission('PSIID', 'java.io.FilePermission', 'd:a.bat','read ,write, execute, delete');

dbms_java.grant_permission('PSIID', 'java.lang.RuntimePermission','*','writeFileDescriptor' );

end;

2、登陆psiid用户创建java程序资源

create or replace and compile

java source named "Util"

as

import java.io.*;

import java.lang.*;

public class Util extends Object

{

public static int RunThis(String args)

{

Runtime rt = Runtime.getRuntime();

int rc = -1;

try

{

Process p = rt.exec(args);

int bufSize = 4096;

BufferedInputStream bis =

new BufferedInputStream(p.getInputStream(), bufSize);

int len;

byte buffer[] = new byte[bufSize];

// Echo back what the program spit out

while ((len = bis.read(buffer, 0, bufSize)) != -1)

System.out.write(buffer, 0, len);

rc = p.waitFor();

}

catch (Exception e)

{

e.printStackTrace();

rc = -1;

}

finally

{

return rc;

}

}

}

3、创建调用Java资源的函数

create or replace function RUN_CMD(p_cmd in varchar2) return number

as

language java name 'Util.RunThis(java.lang.String) return integer';

4、建立一过程调用存储过程

create or replace procedure RUN(p_cmd in varchar2)

as

x number;

begin

x := run_cmd(p_cmd);

end;

------------------------------

------- 执行例子

------------------------------

--d:a.bat 文件

cd d:

rename %1 %2

SQL exec rc('d:a.bat mytest.sql b.sql') ;

D:oracleora92DATABASEcd d:

D:rename mytest.sql b.sql

exec :x := RUN_CMD('ipconfig');

variable x number;

exec dbms_java.set_output(100000);

exec :x := RUN_CMD('ipconfig');

exec :x := RUN_CMD('d:a.bat') ;

java 中怎么实现两个查询可以同时实现

楼主能否说的详细点,我这里认为的是一个方法实现两种不同形式的查询(此处举例:模糊查询、精准查询)

定义vo类A

public class A{

private String name;

private String addr;

...... // get\set方法

}

定义方法B

public list A(A vo){

// vo:包含name、addr

String sql = "Select * from 表名 where 1=1";

1、精准查询

if(vo.getName()!=nullvo.getName().trim()0){

sql += "and 字段 = '"+vo.getName()+"'";

}

2、模糊查询

if(vo.getAddr()!=nullvo.getAddr().trim()0){

sql += "and 字段 like '"+vo.getAddr()+"'";

}

return list结果集;

}

注:不建议使用sql拼接方法进行查询,容易sql注入,此处为了方便才这样编写,希望回答对你有点启发。

java里 这两条sql查询语句怎么合在一起 或者同时执行

不太清楚你要这么做的目的是什么

如果,仅仅只是同时执行 用个union all 即可

如果是想执行这两行sql 当author 为null 用like 查询, 当title 为空 用author 查询,当都为null只用id查询,建议用恒等式,因为if else 代码太多了

nvl(nvl(author ?),1) LIKE nvl(nvl(?, author),1)

AND nvl(nvl( title, ?),1) LIKE nvl(nvl(?, title),1); -- 应该能看懂吧。。。

java如何并行查询的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于java并行处理list、java如何并行查询的信息别忘了在本站进行查找喔。