各位大虾,finally clause cannot complete normally 是什么错阿?
我的程序是:
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
这是什么原因阿?