线程连接数据库读取数据问题,急急急!!!!!!在线等待....................(200分)

  • 主题发起人 flying_bluebird
  • 开始时间
F

flying_bluebird

Unregistered / Unconfirmed
GUEST, unregistred user!
各位老大,遇到一个棘手的问题,请帮忙:
问题描述:
我用一个线程去数据库(sql2000)表读取数据,然后将数据压入一个拥有20个远程调用webservice传输数据的线程的线程池,问题就出来了,这个读取数据的线程会在偶尔的情况下出现不读取数据的情况,请问是怎么回事呢?(tomcat5.59+jdk1.5服务器运行,jb2006开发)
读取数据的线程:
import java.sql.*;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2005</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class GetMtDateThread extends Thread {
private boolean nowgetflag;
//是否开启服务
private int get_ids;
//ids
private String get_mobile;
//号码
private String get_content;
//内容
private String get_fee;
//bind
private String get_linkId;
//linkid
private String get_serviceId;
//serviceid
private String get_utable;
//table
private Connection conn;
private int this_timeCount;
//查询数据库时间间隔
MtThreadPool thisPool = new MtThreadPool(20);
//实例化线程池
MyGetTime thistime = new MyGetTime();
public GetMtDateThread() {
this.nowgetflag = false;
System.out.println("GetMtDateThread is started...... " + thistime.GetTime());
}
public void setRun(boolean isRun) {
this.nowgetflag = isRun;
this_timeCount = 10;
if (isRun) {
System.out.println("GetMtDateThread is running...... " +
thistime.GetTime());
synchronized (this) {
this.notify();
}
}
}
public void run() {
try {
conn = SqlConnect.SqlConnect();
while (true) {
try {
sleep(10);
if (!nowgetflag) {
System.out.println("GetMtDateThread is waiting...... " +thistime.GetTime());
synchronized (this) {
this.wait();
}
}else
{
try {
//System.out.println("GetMtDateThread is running...... "+thistime.GetTime());
sleep(this_timeCount);
if (conn.isClosed()) {
conn = SqlConnect.SqlConnect();
}
ResultSet rs = null;
PreparedStatement pStat = null;
pStat = conn.prepareStatement("SELECT TOP 1 Ids,mobile,content,fee,serviceId,linkId,utable FROM YYGL.CMPP_MT WHERE Status=0 ORDER BY Ids");
rs = pStat.executeQuery();
if (rs.next()) {
this_timeCount = 10;
get_ids = rs.getInt("Ids");
get_mobile = rs.getString("mobile");
get_content = rs.getString("content");
get_fee = rs.getString("fee");
get_serviceId = rs.getString("serviceId");
get_linkId = rs.getString("linkId");
get_utable = rs.getString("utable");
/*插入调用线程池方法*/
System.out.println("GetMt:mobile:" + get_mobile + ";content:" +
get_content + "..." + thistime.GetTime());
while (true) {
sleep(50);
if (thisPool.process(get_mobile, get_content, get_fee,
get_serviceId,
get_linkId, get_utable)){
break;
}
}
//调用结束
pStat.clearBatch();
String this_sql ="update yygl.cmpp_mt set status = '1' where ids =" +get_ids;
pStat = conn.prepareStatement(this_sql);
pStat.executeUpdate();
}else
{
this_timeCount = 2000;
//System.out.println("No date , wait a second try again...... "+thistime.GetTime());
}
} catch (SQLException ex) {
ex.printStackTrace();
}
}
}
catch (InterruptedException e) {
System.out.println("Interrupt");
}
}
}catch (SQLException ex) {
ex.printStackTrace();
}finally {
try {
if (conn != null) {
conn.close();
conn=null;
}
}
catch (SQLException ex1) {
ex1.printStackTrace();
}
}
}
}

另在最初发送数据的时候会出现这样一个警告:
org.apache.axis.utils.javautils isAttachmentSupported
警告:Unable to find required classes <javax.activation.datehandler and javax.mail.internet.MimeMultipart>.Attachment Supprot is disabled.

我在jb中调试没有问题,打包在服务器上运行就出了这个了,或许是打包的问题,但是我找了好久都没有找到,郁闷惨..........................
 

Similar threads

顶部