选择显示字体大小

java多线程数据库操作


  import java.io.*;

import java.sql.*;

public class tooracle {

public static void main(string[] args) {

int n = 10;//每个线程执行的个数

//system.out.println("start action!!!!!!");

tooracle ac = new tooracle();

threadrun[] testrun = new threadrun[21];

for (int i = 1; i <= 21; i++) {

testrun[i] = ac.new threadrun();

testrun[i].trun(n);

system.out.println("线程" + i + "已经启动");

}

//testrun[1] = ac.new threadrun();

//testrun[1].trun(10);

for (int i = 1; i <= 21; i++) {

testrun[i].texit();

}

}

class threadrun {

string blobname = "d:\eclipse\test\test1.txt"; //blob文件名

string clobname = "d:\eclipse\test\test2.txt"; //clob文件名

string in = "insert into ";

string in1 = "(order_id,ric_code,siz,price,trade_datetime,status,testblob,testclob) values(9,&acute;asdfjkl&acute;,21,123.34567,sysdate,&acute;nill逆耳&acute;,?,?)";

string tablename = "orders1";

string sqlstr = ""; // sql 语句

threaduseextends thread = new threaduseextends(blobname, clobname,

sqlstr);

public void trun(int n) {

sqlstr = in + tablename + in1;

thread = new threaduseextends(blobname, clobname, sqlstr);

//thread.start();

thread.run(n);

/*

* int n=10; for (int i = 1; i <= 21; i++) { while(0 <n){ sqlstr[i] =

* in + tablename + in1; thread[i] = new threaduseextends(blobname,

* clobname, sqlstr[i]); thread[i].start(); n--; }

* system.out.println("线程" + i + "已经启动"); }

*/

//system.out.println("线程1已经启动");

}

public void texit() {

thread.interrupt();

}

class threaduseextends extends thread {

string filename1;//blob filename

string filename2;//clob filename

string str;

//构造函数要有(blob文件名,clob文件名,sql语句)

public threaduseextends(string name1, string name2, string sqlstr) {

filename1 = name1;

filename2 = name2;

str = sqlstr;

}

readfiles r1 = new readfiles();

public void run(int n) {

while (n > 0) {

try {

string url = "jdbc:oracle:thin:@193.9.200.111:1521:ora9i";

string login = "system"; // use your login here

string password = "ti2003"; // use your password here

class.forname("oracle.jdbc.driver.oracledriver");

connection con = drivermanager.getconnection(url,

login, password);

string testlong = r1.readfile(filename1);

string testlong1 = r1.readfile(filename2);

byte[] ba = testlong.getbytes();

system.out.println("str=" + str);

//string strsql = str; //"insert into

// orders(order_id,ric_code,siz,price,trade_datetime,status,testblob,testclob)

// values(8,&acute;asdfjkl&acute;,21,123.34567,sysdate,&acute;nill逆耳&acute;,?,?)";

preparedstatement stm = con.preparestatement(str);

stm.setbytes(1, ba);

stringreader test = new stringreader(testlong1);

stm.setcharacterstream(2, test, testlong.length());

stm.execute();

stm.close();

con.close();

} catch (exception e) {

e.printstacktrace();

}

n--;

}//while

}//run

}//threaduseextends class

// readfiles class for read text!!

class readfiles {

public readfiles() {

}

//readfile method,read file

public string readfile(string filename) {

string name = filename;

string file = "";

try {

filereader readf = new filereader(name);//读文件

bufferedreader huanchong = new bufferedreader(readf);//文件读缓冲.

try {

file = huanchong.readline();

} catch (ioexception e1) {

// todo 自动生成 catch 块

e1.printstacktrace();

}

} catch (filenotfoundexception e) {

// todo 自动生成 catch 块

e.printstacktrace();

}

//system.out.println("文件:"+file);

return file;

}

}//readfiles class

}//threadrun class

}//tooracle class


 


关键字 本文所属关键字

相关 与本文相关文章

分类 所有文章关键字导航

源码编程相关

Java   Asp   PHP   .Net   XML   C/C++   CGI   VB   Jsp   J2ee   J2se   J2me   EJB   Servlet   Tomcat   Resin   Struts   Weblogic   Eclipse   ANT   GUI   JMS   Web servise   IDEA   Webphere   Hibernate   Spring   Jboss   Applet   Swing   Socket   Javamail   Perl   Ajax   P2P   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范

Valid CSS!

无不良内容,无不良广告,无恶意代码

Valid XHTML 1.0 Transitional

creativecommons