1. java與網站交互,批量查詢數據得到查詢結果
1270592262
2. java web 資料庫批處理查詢問題!
preparedStatement我不知道有沒有佔位符可以直接傳入一個數組或者是map的功能,如果有的話,在查詢的時候使用 select*from tablename where id in(?);如果沒有的話你就把數組里的id循環取出,然後拼接sql語句,道理是同樣的,這樣你查出來的結果就是一個集合啦,就不用一個一個的查然後再放入二維數組了。 希望可以給樓主一點啟發
3. java executeBatch()方法批量查詢
這個真沒有...
多看下API文檔吧,還有JAVA基礎...
JAVA中批處理語句不返回結果集.
int[] executeBatch()
將一批命令提交給資料庫來執行,如果全部命令執行成功,則返回更新計數組成的數組。
4. 想請問一下關於Java裡面批量執行select語句的問題
這個設計沒能達到理想狀態,程序開發中應盡可能少訪問資料庫。如果你必須同時查詢200次,資料庫表必須建立索引,集合查詢,線程並發。一條查詢花費時間一般是毫秒級。
5. 急,怎麼批量從網站得到查詢結果呢
你如果會用JAVA的話,執行下面的程序,就可以從Baii批量得到查詢結果,
用法:
C:/urltest_files/test_inFile.txt的文件中寫入 要查詢 的關鍵字,每行一個,(當然也可以從DB中讀取 關鍵字,改一下代碼就可以了)
他就會把查詢結果一HTML形式保存到C:/urltest_files/文件中。
因為每個網站都不一樣,不知道他是不是適用於你的網站。
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.net.URL;
import java.net.URLEncoder;
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
try {
String baseUrl = "http://www..com/s?wd=";
String dir = "C:/urltest_files/";
File inFile = new File(dir + "test_inFile.txt");
File outFile = new File(dir + "test_outFile.txt");
if (!inFile.exists()) {
return;
}
OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream(outFile), "GB2312");
Scanner scan = new Scanner(inFile);
int cnt = 0;
while (scan.hasNextLine()) {
cnt++;
String line = scan.nextLine();
try {
URL url = new URL(baseUrl + URLEncoder.encode(line, "GB2312"));
System.out.println(url);
String htmlFile = dir + "result_" + cnt + ".html";
osw.write("KEY: \t" + line + "\r\n");
osw.write("FILE: \t" + htmlFile + "\r\n\r\n");
OutputStreamWriter htmlOut = new OutputStreamWriter(new FileOutputStream(htmlFile), "GB2312");
InputStream ins = url.openStream();
Scanner htmlScan = new Scanner(ins, "GB2312");
while (htmlScan.hasNextLine()) {
htmlOut.write(htmlScan.nextLine() + "\r\n");
}
htmlScan.close();
htmlOut.close();
} catch (Exception e) {
e.printStackTrace();
}
}
scan.close();
osw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
6. java:sql語句批量執行
public static List<List<Map<String, Object>>> getData() {
List<List<Map<String, Object>>> data = new LinkedList<List<Map<String, Object>>>();
data.add(SQLHelper.executeQuery("select * from a"));
data.add(SQLHelper.executeQuery("select * from b"));
data.add(SQLHelper.executeQuery("select * from c"));
data.add(SQLHelper.executeQuery("select * from d"));
return data;
}
7. java中hashtable可以一次性查詢到多條信息么
不是很好用,Hashtable就相當於數組(實際上它內部就是數組原理),要批量查詢不現實,他只能作為一個只能按關鍵字查詢的容器,而且它不能永久保存啊,數據量大的話,有時候還出現溢出錯誤.而資料庫很輕松就可以辦到啊,多熟悉熟悉資料庫,應該很容易運用的.