| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 856 人关注过本帖
标题:一个java文件的编译
只看楼主 加入收藏
JspTop
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2006-8-19
收藏
 问题点数:0 回复次数:4 
一个java文件的编译

这个文件是我反编译过的,没有经过修改,重新编译时为什么总提示: exception;有错误??

package operate_db;

import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.sql.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.sql.DataSource;
import sun.jdbc.rowset.CachedRowSet;

public class OperateDb
{

protected String query_statement;
protected String param[];
protected Connection conn;
protected String jndiname;
private String conTime;
private boolean isConnected;
public static int conCount = 0;

public OperateDb()
{
query_statement = "";
conn = null;
isConnected = false;
}

protected void setParam(String as[])
{
param = as;
}

private void setQuerystatement(String s)
{
query_statement = s;
}

public Connection getConn()
{
return conn;
}

public void dbConn()
throws Exception
{
if(isConnected)
return;
Object obj = null;
DataSource datasource = null;
if(conCount % 100 == 0)
System.out.println(conCount + "," + Runtime.getRuntime().totalMemory());
try
{
InitialContext initialcontext = new InitialContext();
if(initialcontext == null)
throw new Exception(" Context not Find");
if(datasource == null)
datasource = (DataSource)initialcontext.lookup(jndiname);
if(datasource != null)
{
Connection connection = datasource.getConnection();
if(connection == null)
throw new Exception(jndiname + " connecte fail! ");
isConnected = true;
conn = connection;
conCount++;
initialcontext.close();
}
}
catch(Exception exception)
{
System.out.println(exception.getMessage());
throw new Exception(toString() + " error DataBase " + jndiname + " Connect Fail,Please Wait For 5 Minutes!");
}
}

public void dbClose()
throws Exception
{
if(conn != null && isConnected && !conn.isClosed())
{
isConnected = false;
conn.close();
}
}

protected ResultSet getResult()
{
ResultSet resultset = null;
try
{
PreparedStatement preparedstatement = conn.prepareStatement(query_statement, 1004, 1007);
if(param != null)
{
for(int i = 0; i < param.length; i++)
preparedstatement.setString(i + 1, param[i]);

}
resultset = preparedstatement.executeQuery();
}
catch(Exception exception)
{
System.out.println(exception);
}
return resultset;
}

private int updateRecordDb()
throws SQLException, UnsupportedEncodingException
{
dbConn();
if(!isConnected)
throw new Exception(jndiname + " not connected");
PreparedStatement preparedstatement = conn.prepareStatement(query_statement);
if(param != null)
{
for(int i = 0; i < param.length; i++)
preparedstatement.setString(i + 1, param[i]);

}
preparedstatement.executeUpdate();
preparedstatement.close();
conn.commit();
dbClose();
return 1;
Exception exception;
exception;
System.out.println("updateRecordDb failed:\r\n" + query_statement + " " + exception);
conn.rollback();
return -1;
}

private int updateRecord()
throws SQLException, UnsupportedEncodingException
{
PreparedStatement preparedstatement = conn.prepareStatement(query_statement);
if(param != null)
{
for(int i = 0; i < param.length; i++)
preparedstatement.setString(i + 1, param[i]);

}
preparedstatement.executeUpdate();
preparedstatement.close();
conn.commit();
return 1;
Exception exception;
exception;
System.out.println(exception);
conn.rollback();
return -1;
}

public boolean isHaveField(String s, String s1, String s2)
{
query_statement = "select count(*) as countnum from " + s + " where " + s1 + "='" + s2 + "'";
Object obj = null;
int i;
if(!isConnected)
throw new Exception(jndiname + " not connected");
setQuerystatement(query_statement);
ResultSet resultset = getResult();
resultset.next();
i = resultset.getInt(1);
resultset.close();
if(i > 0)
return true;
return false;
Exception exception;
exception;
System.out.println(exception);
return true;
}

public boolean isHaveField(String s, String s1, long l)
{
query_statement = "select count(*) as countnum from " + s + " where " + s1 + "=" + l;
Object obj = null;
int i;
dbConn();
if(!isConnected)
throw new Exception(jndiname + " not connected");
setQuerystatement(query_statement);
ResultSet resultset = getResult();
resultset.next();
i = resultset.getInt(1);
resultset.close();
dbClose();
if(i > 0)
return true;
return false;
Exception exception;
exception;
System.out.println(exception);
return true;
}

public ResultSet getResult(String s)
{
ResultSet resultset = null;
try
{
if(!isConnected)
dbConn();
if(!isConnected)
throw new Exception(jndiname + " not connected");
setQuerystatement(s);
resultset = getResult();
}
catch(Exception exception)
{
System.out.println("getResult: " + s + ": " + exception);
}
return resultset;
}

public int exeCute(String s)
{
if(!isConnected)
throw new Exception(jndiname + " not connected");
setQuerystatement(s);
return updateRecord();
Exception exception;
exception;
System.out.println("exeCute1: " + s + ": " + exception);
return -1;
}

public int exeSql(String s)
{
setQuerystatement(s);
return updateRecordDb();
Exception exception;
exception;
System.out.println("exeSql: " + s + ": " + exception);
System.out.println(exception);
return -1;
}

public CachedRowSet getRowSet(String s)
{
CachedRowSet cachedrowset = null;
setQuerystatement(s);
try
{
dbConn();
if(!isConnected)
throw new Exception(jndiname + " not connected");
PreparedStatement preparedstatement = conn.prepareStatement(query_statement, 1004, 1008);
if(param != null)
{
for(int i = 0; i < param.length; i++)
preparedstatement.setString(i + 1, param[i]);

}
ResultSet resultset = preparedstatement.executeQuery();
cachedrowset = new CachedRowSet();
cachedrowset.populate(resultset);
preparedstatement.close();
resultset.close();
dbClose();
}
catch(SQLException sqlexception)
{
System.out.println("Error occurs in queryRowSet");
cachedrowset = null;
}
catch(Exception exception)
{
System.out.println(exception.getMessage());
cachedrowset = null;
}
finally
{
return cachedrowset;
}
do
;
while(true);
}

public String computeDouble(String s, String s1, String s2)
{
String s3;
String s4;
s3 = "0";
if(s == null)
s = "";
if("".equals(s))
s = "0";
if(s1 == null)
s1 = "";
if("".equals(s1))
s1 = "0";
s4 = "select " + s + s2 + s1 + " as rtn";
ResultSet resultset = getResult(s4);
if(resultset.next())
{
s3 = resultset.getString("rtn");
if(s3 == null)
s3 = "0";
}
resultset.close();
return s3;
Exception exception;
exception;
System.out.println(exception);
return "0";
}

}


PiepK1yk.rar (57.45 KB) 一个java的编译


[此贴子已经被作者于2006-8-21 18:46:43编辑过]



iPuvBipf.rar (56.25 KB) 一个java的编译

搜索更多相关主题的帖子: java import 文件 编译 protected 
2006-08-21 18:38
神vLinux飘飘
Rank: 13Rank: 13Rank: 13Rank: 13
来 自:浙江杭州
等 级:贵宾
威 望:91
帖 子:6140
专家分:217
注 册:2004-7-17
收藏
得分:0 
我不方便手工编译,能把详细的错误贴出来么

淘宝杜琨
2006-08-21 21:43
JspTop
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2006-8-19
收藏
得分:0 
谢谢斑竹的关注,我的问题一解决:
在有可能出现异常的语句中加上 try{...}catch(Exception e){} 语句~~
try{
int i = 1/j;//很明显除数不能为0,这句就有可能抛出异常
}
catch(Exception e){}
2006-08-22 16:56
神vLinux飘飘
Rank: 13Rank: 13Rank: 13Rank: 13
来 自:浙江杭州
等 级:贵宾
威 望:91
帖 子:6140
专家分:217
注 册:2004-7-17
收藏
得分:0 
呵呵,
你这样解决异常可不大好~

淘宝杜琨
2006-08-22 17:16
xqiang
Rank: 1
等 级:新手上路
帖 子:291
专家分:0
注 册:2006-2-23
收藏
得分:0 
楼主,
可不可以告诉我怎么反编译.CLASS文件啊?

呵呵

相信自己可以的!!! http://www.
2006-08-23 08:51
快速回复:一个java文件的编译
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.024973 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved