。。不能帖图。。写出来。
cannot access com.royobo.Connec,bad class file: d:/JBuilder/lib/ext/liuyan.jar/com/royobo/Connec.Class,
class file contains wrong class:liuyan.Connec,Pleaase remove or make sure it appears in the correct subdirectory of the classpath at line 2(2:19)
jar的文件是用jdk1.4下的jar生成的。怎么说bad class...奇怪万分。请大家指点下。
cannot access com.royobo.Connec,bad class file: d:/JBuilder/lib/ext/liuyan.jar/com/royobo/Connec.Class,
class file contains wrong class:liuyan.Connec,Pleaase remove or make sure it appears in the correct subdirectory of the classpath at line 2(2:19)
jar的文件是用jdk1.4下的jar生成的。怎么说bad class...奇怪万分。请大家指点下。
import org.gjt.mm.mysql.Driver;public class Connec {
private Connection con = null;
private ResultSet rs = null; public Connec() {
try {
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
con = DriverManager.getConnection(
"jdbc:mysql://localserver?autoReconnect=true", "root", "root");
}
catch (java.lang.ClassNotFoundException e) {
System.err.println(e);
}
catch (SQLException e) {
System.err.println(e);
}
catch (Exception e) {
}
} public void executeUpdate(String sql)throws Exception{
//sql=new String(sql.getBytes("GBK"),"ISO8859_1");
try{
Statement stmt=con.createStatement();
stmt.executeUpdate(sql);
con.close();
stmt.close();
}catch(SQLException e){
System.err.println(e);
}
} public ResultSet executeQuery(String sql)throws Exception{
rs=null;
try{
//sql=new String(sql.getBytes("GBK"),"ISO8859_1");
Statement stmt=con.createStatement();
rs=stmt.executeQuery(sql);
}catch(SQLException e){
System.err.println(e);
}
return rs;
} public void CloseCon() throws Exception {
try{
if (rs!=null)
rs.close();
if (con!=null)
con.close();
}catch(SQLException e)
{
System.err.println(e);
}
}}
请大家帮忙看下。
这个类编译是通过的。在类自身中调用也可以。。
做成JAR就不行了
你的Connec类在package liuyan下
而打包成jar时,却放到了com/royobo下
所以会报错,两个路径要一致
就可以了么?