各位大虾,finally clause cannot complete normally 是什么错阿?

Odysseus_110 2005-05-18 11:02:53
我的程序是:
package BookShop;

import java.sql.*;
import javax.sql.*;
import javax.naming.*;

public class MyDb{
private Context ctx=null;
private DataSource ds=null;
private static Connection conn=null;
private Statement stmt=null;
private ResultSet rs=null;
private static int COUNT=0;

public MyDb(){

}


public void close(){
try{
if (rs !=null) rs.close();
}catch(Exception e){
e.printStackTrace(System.err);
}
try{
if(stmt!=null) stmt.close();
}catch(Exception e){
e.printStackTrace(System.err);
}
try{
if(conn!=null) {
conn.close();
// System.err.println("count -- "+(--COUNT));
}
}catch(Exception e){
e.printStackTrace(System.err);
}
}


public int select(String sql){
int k=-10;
try{
k=0;
rs=this.getstmtread().executeQuery(sql);
while(rs.next()){
k++;
}
}catch(Exception e){
k=-1;
e.printStackTrace(System.err);
}finally{
this.close();
}
return k;
}


public Connection getCon(){
try{
ctx = new InitialContext();
ds = (DataSource)ctx.lookup("java:comp/env/jdbc/BookShop");
conn = ds.getConnection();
// System.err.println("count ++ "+(++COUNT));
}catch(Exception e){
e.printStackTrace(System.err);
}
return conn;
}

public int update(String sql){
int k=-10;
try{
k=0;
k=this.getstmt().executeUpdate(sql);
}catch(Exception e){
k=-1;
e.printStackTrace(System.err);
}finally{
this.close();
return k;
}
}


public Statement getstmtread(){
try{
conn=getCon();
stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
}catch(Exception e){
e.printStackTrace(System.err);
}
return stmt;
}


public Statement getstmt(){
try{
conn=getCon();
stmt=conn.createStatement();
}catch(Exception e){
e.printStackTrace(System.err);
}
return stmt;
}


public String inStr(String str){
if(str==null){
str="";
}else{
try{
str=(new String(str.getBytes("iso-8859-1"),"GB2312")).trim();
str=str.replace('\'',(char)1);
}catch(Exception e){
e.printStackTrace(System.err);
}
}
return str;
}


public String outStr(String str){
if(str==null){
str="";
}else{
try{
str=str.replace((char)1,'\'');
}catch(Exception e){
e.printStackTrace(System.err);
}
}
return str;
}


public String selectStr(String str){

if(str.equals("")){
str=" LIKE '%' ";
}else{
str=(" LIKE '%"+str+"%' ");
}
return str;
}
}

报的错是:
MyDb.java:83: warning: finally clause cannot complete normally
}
^
1 warning
Exit code: 0
No Errors
这是什么原因阿?
...全文
90 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
xindear 2005-06-02
  • 打赏
  • 举报
回复
我也遇到这个问题
哪位大哥解释一下哈
mnbvc874 2005-05-19
  • 打赏
  • 举报
回复
最好加个注释

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧