java数据库,出现java.lang.ClassNotFoundException 问题

package S;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;

public class JDBCS {
String url = "jdbc:mysql://localhost:3307/ty10";
String name = "root";
String password = "mysql";
Connection conn = null;
PreparedStatement pps=null;
ResultSet rs = null;

JDBCS() {
    try {
        Class.forName("com.mysql.jdbc.Driver");
        conn = DriverManager.getConnection(url,name,password);
    } catch (ClassNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

void update(String sql,String[] val){

    try {

        pps = conn.prepareStatement(sql);

        for (int i = 0; val!=null && i < val.length; i++) {
            pps.setString(i+1, val[i]);
        }

        pps.executeUpdate();

    }catch (SQLException e) {
        e.printStackTrace();
    }
}

ArrayList> queryToList(String sql ,String[] val){

rs=query(sql,val);

ArrayList<HashMap<String ,String>> list = new ArrayList<HashMap<String,String>>();

try {
    ResultSetMetaData mt = rs.getMetaData();//结果集结构对象(有啥字段,类型,长度。。。)

    while(rs.next()){
        HashMap<String ,String> map = new HashMap<String ,String>();

        for (int i = 0; i < mt.getColumnCount(); i++) {//取所有字段

            String name = mt.getColumnName( i+1 );//获取列名
            map.put(name, rs.getString(name));

        }

        list.add(map);
    }
} catch (SQLException e) {
    e.printStackTrace();
}


return list ;

}

ResultSet query(String sql ,String[] val){

try {

    pps = conn.prepareStatement(sql);

    for (int i = 0; val!=null && i < val.length; i++) {
        pps.setString(i+1, val[i]);
    }

    rs = pps.executeQuery();
    return rs ;
}catch (SQLException e) {
    e.printStackTrace();
}
return null;

}
void close(){

try {
    rs.close();
} catch (SQLException e2) {
    e2.printStackTrace();
}

try {
    pps.close();
} catch (SQLException e1) {
    e1.printStackTrace();
}

try {
    conn.close();
} catch (SQLException e) {
    e.printStackTrace();
}

}
}
运行后错误提示
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at S.JDBCS.(JDBCS.java:22)
at S.student2.main(student2.java:9)
Exception in thread "main" java.lang.NullPointerException
at S.JDBCS.query(JDBCS.java:81)
at S.student2.main(student2.java:10)

6个回答

com.mysql.jdbc.Driver驱动类无法找到,是不是驱动JAR包没有拷贝到项目的lib下

k_kno1
demontown 你好,project的lib在哪啊
大约一年之前 回复

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
很清楚,你的jdbc驱动类没有

http://nankaijerry.iteye.com/blog/1826921
这个人跟你一个问题,你看他的解决方法,你能不能用

很明显就是jdbc类没有找到,是不是路径有问题

jdbc驱动类加载错误,看看有没有jar包,以及类名路径是否正确

找不到jdbc驱动,你看看有没有将jdbc加载到工程里。

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
Python+OpenCV计算机视觉

Python+OpenCV计算机视觉

JDBC驱动加载失败,异常:java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

昨天写一个Swing小程序,用JDBC连接数据库,运行的时候报java.lang.ClassNotFoundException: com.mysql.jdbc.Driver这个异常。 于是写一个小demo测试一下: ``` package fly; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; public class test2 { Connection connection; public Connection getConnection(){ try { Class.forName("com.mysql.jdbc.Driver"); System.out.println("数据库驱动加载成功"); } catch (ClassNotFoundException e) { e.printStackTrace(); } try { connection= DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root"); System.out.println("连接成功"); } catch (SQLException e) { e.printStackTrace(); } return connection; } public static void main(String[] args) { test2 test2=new test2(); test2.getConnection(); } } ``` 运行报异常如下: ``` "C:\Program Files\Java\jdk1.8.0_201\bin\java.exe" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2018.3.6\lib\idea_rt.jar=6199:C:\Program Files\JetBrains\IntelliJ IDEA 2018.3.6\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.8.0_201\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_201\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_201\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_201\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_201\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_201\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_201\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_201\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_201\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_201\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_201\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_201\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_201\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_201\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_201\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_201\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_201\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_201\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_201\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_201\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_201\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_201\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_201\jre\lib\rt.jar;E:\JavaData\SwingProgram\out\production\SwingProgram" fly.test2 java.lang.ClassNotFoundException: com.mysql.jdbc.Driver at java.net.URLClassLoader.findClass(URLClassLoader.java:382) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:264) at fly.test2.getConnection(test2.java:11) at fly.test2.main(test2.java:28) java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/test at java.sql.DriverManager.getConnection(DriverManager.java:689) at java.sql.DriverManager.getConnection(DriverManager.java:247) at fly.test2.getConnection(test2.java:17) at fly.test2.main(test2.java:28) Process finished with exit code 0 ``` 真是心态爆炸,希望知道是什么问题的大佬指点一下迷津,感激不尽!!!!

java.lang.ClassNotFoundException: com.mysql.cj.jdbc.Driver已在lib下添加jar包还是报错怎么办

在网上好了很多的问题 都没有解决,针对web,大家用的都是的在tomcat下的lib里添加mysql-connector的jar包 但是还是没有解决 还是连接不上,也在url里面添加后缀了 package jdbc; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Statement; public class JDBCDemo { private static final String URL="jdbc:mysql://localhost:3306/db4?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Hongkong"; private static final String USERNAME="root"; private static final String PWD="root"; public static void update() {//增删改 Connection connection=null; Statement stmt =null; try { //导入驱动,加载具体驱动类 Class.forName("com.mysql.cj.jdbc.Driver");//加载具体的驱动类 //与数据库建立连接 connection=DriverManager.getConnection(URL,USERNAME,PWD); //增删改 stmt = connection.createStatement(); String sql="insert into student values(4,'kxk','123')"; int result = stmt.executeUpdate(sql); //处理结果:显示受影响行数 System.out.println(result); }catch (ClassNotFoundException e) { e.printStackTrace(); }catch (Exception e) { e.printStackTrace(); }finally { if(stmt!=null) { try { stmt.close(); }catch (SQLException e) { e.printStackTrace(); } } if(connection!=null) { try { connection.close(); }catch (SQLException e) { e.printStackTrace(); } } } } public static void main(String[] args) { update(); } } 报错还是 java.lang.ClassNotFoundException: com.mysql.cj.jdbc.Driver at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:264) 不知道哪里出现了问题,求助

Stacktrace:] with root cause java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

org.apache.jasper.JasperException: 在 [17] 行处理 [find stu_1.jsp] 时发生异常 14: String url2="?user="+userName+"&password="+userPwd; 15: String url3="&useUnicode=true&characterEncoding=utf-8"; 16: String url=url1+url2+url3; 17: Class.forName(driverName); 18: Connection conn=DriverManager.getConnection(url); 19: String sql="select * from stu_info"; 20: PreparedStatement pstmt=conn.prepareStatement(sql); Stacktrace: org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:626) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:500) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329) javax.servlet.http.HttpServlet.service(HttpServlet.java:741) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) Root Cause javax.servlet.ServletException: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:666) org.apache.jsp.find_0020stu_005f1_jsp._jspService(find_0020stu_005f1_jsp.java:201) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:71) javax.servlet.http.HttpServlet.service(HttpServlet.java:741) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:477) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329) javax.servlet.http.HttpServlet.service(HttpServlet.java:741) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) Root Cause java.lang.ClassNotFoundException: com.mysql.jdbc.Driver org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1365) org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1188) org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:122) org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:59) java.lang.Class.forName0(Native Method) java.lang.Class.forName(Class.java:264) org.apache.jsp.find_0020stu_005f1_jsp._jspService(find_0020stu_005f1_jsp.java:135) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:71) javax.servlet.http.HttpServlet.service(HttpServlet.java:741) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:477) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329) javax.servlet.http.HttpServlet.service(HttpServlet.java:741) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) ):注意 主要问题的全部 stack 信息可以在 server logs 里查看 Stacktrace:] with root cause java.lang.ClassNotFoundException: com.mysql.jdbc.Driver at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1365) at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1188) at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:122) at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:59) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:264) at org.apache.jsp.find_0020stu_005f1_jsp._jspService(find_0020stu_005f1_jsp.java:135) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:71) at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:477) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329) at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:690) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:373) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1590) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:748) 小白求大佬解答,jsp连接数据库运行后出现异常,下面是主要代码: <%@ page contentType="text/html; charset=GB18030" import="java.sql.*"%> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=GB18030"> <title>显示所有学生的页面</title> </head> <body> <center> <%String driverName="com.mysql.jdbc.Driver"; String userName="root"; String userPwd="root"; String dbName="student"; String url1="jdbc:mysql//localhost:3306/"+dbName; String url2="?user="+userName+"&password="+userPwd; String url3="&useUnicode=true&characterEncoding=utf-8"; String url=url1+url2+url3; Class.forName(driverName); Connection conn=DriverManager.getConnection(url); String sql="select * from stu_info"; PreparedStatement pstmt=conn.prepareStatement(sql); ResultSet rs=pstmt.executeQuery(); rs.last(); %>

jdbc驱动异常,出现“java.lang.ClassNotFoundException: com.mysql.jdbc.Drive”错误是怎么回事?

jar已经引入并建立路径了,还是出现这个错误。数据库是mysql5.7 ![图片说明](https://img-ask.csdn.net/upload/202003/31/1585654607_93452.png)

项目中已经导入了class文件为什么还会出现java.lang.ClassNotFoundException

我在连接jsp的mssqlserver2000时出现这种情况,但是我的项目已经导入了红色区域的三个数据库连接的jar文件,并且用以下代码测试并通过,可是在jsp运行时却老是出现下面的错误提示。重启电脑还是一样的,没有效果。以前出现找不到类时,立即重启还是一样,但过了一天以后启动就可以了,不知道究竟是是哪里行不通???请各位帮忙……

java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver

连接SQL2005 是出现:java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver的问题 已经看过网上发的很多帖子,也试过很多方法都没有解决。 一样的代码在java项目中没问题,放到一个插件项目中出现上面的问题(驱动包以加到插件项目中) PS:我是想把数据库中的表名和字段名取出来

萌新java连接MySQL数据库出现java.lang.NullPointerException错误是为什么,求大佬看一下代码解答

package Stu; import java.util.*; public class StuManage { public void menu(){ connectSQL s=new connectSQL(); int xuhao; String b1 = null,c1=null,b111=null; int a = 0,a1=0,b11=0,c11=0; Scanner scanner=new Scanner(System.in); System.out.println("欢迎来到学生信息管理系统"); System.out.println("1.新增学生"); System.out.println("2.修改学生"); System.out.println("3.删除学生"); System.out.println("4.查询学生"); System.out.println("5.显示所有学生信息"); System.out.println("6.退出该系统"); System.out.println("请选择(1-5):"); xuhao=scanner.nextInt(); switch (xuhao) { case 1: s.open(); stuadd(); s.down(); break; case 2: update(); break; case 3: studel(); s.open(); s.shanchu(a); s.down(); break; case 4: stuList(); s.open(); s.chaxun(b11); s.down(); break; case 5: xianshi(); s.open(); s.xianshi(); s.down(); break; case 6: System.exit(0); break; default: System.out.println("输入有误:程序自动退出,请重启程序"); break; } } public void stuadd(){ connectSQL x=new connectSQL(); Scanner s=new Scanner(System.in); String select,jieshou,name=null; int no=0,phone=0; System.out.println("====新增学生===="); System.out.println("学号:"); no=s.nextInt(); jieshou=s.nextLine(); System.out.println("姓名:"); name=s.nextLine(); System.out.println("手机号:"); phone=s.nextInt(); System.out.println("您输入的信息为:学号:"+no+" "+"姓名:"+name+" "+"手机号:"+phone); System.out.println("是否保存?y/n"); jieshou=s.nextLine(); select=s.nextLine(); if(select.equals("y")){ x.tianjia(no,name,phone); System.out.println("保存成功!"); } else if(select.equals("n")){ System.out.println("请重新输入"); } } package Stu; import java.sql.*; public class connectSQL { Connection con=null; PreparedStatement st=null; ResultSet rs=null; public void open(){ try { Class.forName("com.mysql.jdbc.Driver"); } catch (ClassNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } String uri="jdbc:mysql://localhost:3306/qinyewei?user=root&password=123456&userSSL=ture"; try{ con=DriverManager.getConnection(uri); } catch(SQLException e){ System.out.println(e); } } public void down(){ try { con.close(); } catch (SQLException e) { // TODO 自动生成的 catch 块 e.printStackTrace(); } } void xianshi(){ try{ st=con.prepareStatement("select * from stu"); rs=st.executeQuery(); while(rs.next()) { String a=rs.getString(1); String b=rs.getString(2); String c=rs.getString(3); System.out.printf("%s\t",a); System.out.printf("%5s\t",b); System.out.println(c); } } catch (SQLException e) { // TODO 自动生成的 catch 块 e.printStackTrace(); } } void tianjia(int a1,String b1,int c1) { try { System.out.println(a1); System.out.println(b1); System.out.println(c1); st=con.prepareStatement("insert stu values(?,?,?)"); st.setInt(1,a1); st.setString(2,b1); st.setInt(3,c1); int i=st.executeUpdate(); System.out.println("添加了"+i+"条记录"); this.xianshi(); } catch (Exception e) { // TODO 自动生成的 catch 块 e.printStackTrace(); } } 运行后输入1、学号、姓名、手机号以后出现错误是为什么呢? 欢迎来到学生信息管理系统 1.新增学生 2.修改学生 3.删除学生 4.查询学生 5.显示所有学生信息 6.退出该系统 请选择(1-5): 1 ====新增学生==== 学号: 123123 姓名: weqwe 手机号: 123123 您输入的信息为:学号:123123 姓名:weqwe 手机号:123123 是否保存?y/n y 123123 weqwe 123123 java.lang.NullPointerException保存成功! at Stu.connectSQL.tianjia(connectSQL.java:56) at Stu.StuManage.stuadd(StuManage.java:72) at Stu.StuManage.menu(StuManage.java:22) at Stu.Main.main(Main.java:7) 第56行代码是 st=con.prepareStatement("insert stu values(?,?,?)");

LAMP18.04下javaweb项目用JDBC连接mysql5.7.28失败,报错java.lang.ClassNotFoundException: com.mysql.cj.jdbc.Driver

![图片说明](https://img-ask.csdn.net/upload/202004/28/1588078729_897594.png) 这个是云服务器运行连接数据库的字节码文件,连接成功会输出一句话“连接数据库成功”。 但奇怪的是,**这个项目在本机上运行没有报错**。更奇怪的是,这个部署在云服务器上的项目**jsp页面有时可以将数据库的内容输出出来,**也可以进行增删改查等操作。但大概一晚上就连接不到了。 第一:我进行了如下努力。本机的数据库版本较高,所以又加入了 mysql-connector-java-5.1.47的包。 ![图片说明](https://img-ask.csdn.net/upload/202004/28/1588079666_343267.png) 第二,我在本机上连接云服务器的数据库,连接成功。但在云服务器上总是不稳定,(**_因此我认为我的数据库连接的jar包应该成功加入了项目,不然本地怎么能连接云服务器的数据库呢,而且数据库信息肯定是正确的_**) 第三:我目前的驱动是driver = "com.mysql.cj.jdbc.Driver"。 这个网上显示mysql5.7应该使用"com.mysql.jdbc.Driver",但我使用这个就会报错java.lang.ClassNotFoundException: com.mysql.jdbc.Driver **有一个明显的规律**。如果jsp页面没有显示数据库内容,只要我将war包解压后的文件夹删除,重新访问生成新的文件夹,jsp页面就可以显示数据库的内容,可以增删改查 希望哥哥姐姐们如果知道或者有其他想法可以解答一下!拜托了

在Android Studio使用jdbc连接MySQL遇到java.lang.ExceptionInInitializerError

使用jdbc的方法在安卓项目中连接MySQL数据库,在getConnection()时出现java.lang.ExceptionInInitializerError,实在不懂错在哪了... ![图片说明](https://img-ask.csdn.net/upload/201910/21/1571662749_861983.png)

Exception in thread "main" java.lang.NoClassDefFoundError,有导入对应jar包,但显示无法找到对应类?

**spring项目,main函数中调用ApplicationContext类** ``` import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; public class Main { public static void main(String[] args) { ApplicationContext context = new ClassPathXmlApplicationContext("Beans.xml"); TextEditor te = (TextEditor) context.getBean("textEditor"); te.spellCheck(); } } ``` **也有导入相应jar包** ![图片说明](https://img-ask.csdn.net/upload/201902/12/1549956155_70845.png) **但是运行后会提示** ![图片说明](https://img-ask.csdn.net/upload/201902/12/1549956248_826403.png) **且报错如下** ``` Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContext at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) at java.lang.Class.privateGetMethodRecursive(Class.java:3048) at java.lang.Class.getMethod0(Class.java:3018) at java.lang.Class.getMethod(Class.java:1784) at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544) at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526) Caused by: java.lang.ClassNotFoundException: org.springframework.context.ApplicationContext at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 7 more ``` **请问应如何解决呢?**

hadoop hive 初始化报错

环境:centos7 hadoop3.1.2 hive2.3.0 [root@hadoop metastore]# schematool -initSchema -dbType mysql Exception in thread "main" java.lang.ClassNotFoundException: org.apache.hive.beeline.HiveSchemaTool at java.net.URLClassLoader.findClass(URLClassLoader.java:382) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:348) at org.apache.hadoop.util.RunJar.run(RunJar.java:311) at org.apache.hadoop.util.RunJar.main(RunJar.java:232) [root@hadoop metastore]# hive which: no hbase in (/root/mysql/apache-hive-2.3.0-bin/bin:/root/train/hadoop-3.1.2/sbin:/root/train/hadoop-3.1.2/bin:/root/train/jdk1.8.0_211/bin:/root/train/hive/bin:/root/train/hadoop-3.1.2/sbin:/root/train/hadoop-3.1.2/bin:/root/train/jdk1.8.0_211/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin) Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/hive/ql/CommandNeedRetryException at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:348) at org.apache.hadoop.util.RunJar.run(RunJar.java:311) at org.apache.hadoop.util.RunJar.main(RunJar.java:232) Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.hive.ql.CommandNeedRetryException at java.net.URLClassLoader.findClass(URLClassLoader.java:382) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 4 more Navicat Premium 都能成功登入mysql建立的hive数据库 hive 配置文件都没问题 mysql连接器也放入了lib

这个异常怎么解决 谢谢!

![图片说明](https://img-ask.csdn.net/upload/201803/26/1522026367_658580.png) ibatis写的增删改差连接的mysql数据库.谢谢! 三月 26, 2018 1:51:08 下午 com.ibatis.common.logging.jdk14.Jdk14LoggingImpl error 严重: SimpleDataSource: Error while loading properties. Cause: java.lang.ClassNotFoundException: driver java.lang.ClassNotFoundException: driver at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:195) at com.ibatis.common.resources.Resources.classForName(Resources.java:265) at com.ibatis.common.resources.Resources.instantiate(Resources.java:281) at com.ibatis.common.jdbc.SimpleDataSource.initialize(SimpleDataSource.java:199) at com.ibatis.common.jdbc.SimpleDataSource.<init>(SimpleDataSource.java:116) at com.ibatis.sqlmap.engine.datasource.SimpleDataSourceFactory.initialize(SimpleDataSourceFactory.java:31) at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser$9.process(SqlMapConfigParser.java:347) at com.ibatis.common.xml.NodeletParser.processNodelet(NodeletParser.java:121) at com.ibatis.common.xml.NodeletParser.process(NodeletParser.java:105) at com.ibatis.common.xml.NodeletParser.process(NodeletParser.java:102) at com.ibatis.common.xml.NodeletParser.process(NodeletParser.java:102) at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:72) at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:51) at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser.parse(SqlMapConfigParser.java:86) at com.ibatis.sqlmap.client.SqlMapClientBuilder.buildSqlMapClient(SqlMapClientBuilder.java:63) at com.ahedu.IStudentDAOImpl.<clinit>(IStudentDAOImpl.java:16) Exception in thread "main" java.lang.ExceptionInInitializerError Caused by: java.lang.RuntimeException: Error occurred. Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: java.lang.RuntimeException: Error parsing XPath '/sqlMapConfig/transactionManager/dataSource/end()'. Cause: com.ibatis.sqlmap.client.SqlMapException: Error initializing DataSource. Could not instantiate DataSourceFactory. Cause: java.lang.RuntimeException: SimpleDataSource: Error while loading properties. Cause: java.lang.ClassNotFoundException: driver at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser.parse(SqlMapConfigParser.java:89) at com.ibatis.sqlmap.client.SqlMapClientBuilder.buildSqlMapClient(SqlMapClientBuilder.java:63) at com.ahedu.IStudentDAOImpl.<clinit>(IStudentDAOImpl.java:16) Caused by: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: java.lang.RuntimeException: Error parsing XPath '/sqlMapConfig/transactionManager/dataSource/end()'. Cause: com.ibatis.sqlmap.client.SqlMapException: Error initializing DataSource. Could not instantiate DataSourceFactory. Cause: java.lang.RuntimeException: SimpleDataSource: Error while loading properties. Cause: java.lang.ClassNotFoundException: driver at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:53) at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser.parse(SqlMapConfigParser.java:86) ... 2 more Caused by: java.lang.RuntimeException: Error parsing XPath '/sqlMapConfig/transactionManager/dataSource/end()'. Cause: com.ibatis.sqlmap.client.SqlMapException: Error initializing DataSource. Could not instantiate DataSourceFactory. Cause: java.lang.RuntimeException: SimpleDataSource: Error while loading properties. Cause: java.lang.ClassNotFoundException: driver at com.ibatis.common.xml.NodeletParser.processNodelet(NodeletParser.java:123) at com.ibatis.common.xml.NodeletParser.process(NodeletParser.java:105) at com.ibatis.common.xml.NodeletParser.process(NodeletParser.java:102) at com.ibatis.common.xml.NodeletParser.process(NodeletParser.java:102) at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:72) at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:51) ... 3 more Caused by: com.ibatis.sqlmap.client.SqlMapException: Error initializing DataSource. Could not instantiate DataSourceFactory. Cause: java.lang.RuntimeException: SimpleDataSource: Error while loading properties. Cause: java.lang.ClassNotFoundException: driver at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser$9.process(SqlMapConfigParser.java:354) at com.ibatis.common.xml.NodeletParser.processNodelet(NodeletParser.java:121) ... 8 more Caused by: java.lang.RuntimeException: SimpleDataSource: Error while loading properties. Cause: java.lang.ClassNotFoundException: driver at com.ibatis.common.jdbc.SimpleDataSource.initialize(SimpleDataSource.java:210) at com.ibatis.common.jdbc.SimpleDataSource.<init>(SimpleDataSource.java:116) at com.ibatis.sqlmap.engine.datasource.SimpleDataSourceFactory.initialize(SimpleDataSourceFactory.java:31) at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser$9.process(SqlMapConfigParser.java:347) ... 9 more Caused by: java.lang.ClassNotFoundException: driver at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:195) at com.ibatis.common.resources.Resources.classForName(Resources.java:265) at com.ibatis.common.resources.Resources.instantiate(Resources.java:281) at com.ibatis.common.jdbc.SimpleDataSource.initialize(SimpleDataSource.java:199) ... 12 more ![图片说明](https://img-ask.csdn.net/upload/201803/26/1522045555_391520.png) 什么原因啊 弄了好久了!

ssm项目:明明已经导入jar包,但运行时却报ClassNotFoundException异常。

异常信息如下: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.mybatis.spring.SqlSessionFactoryBean.class] for bean with name 'sessionFactory' defined in class path resource [spring/applicationContext-dao.xml]; nested exception is java.lang.ClassNotFoundException: org.mybatis.spring.SqlSessionFactoryBean.class at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1275) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:575) at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1344) at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:910) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:609) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83) at com.yong.mapper.UserMapperTest.setUp(UserMapperTest.java:18) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) at org.junit.runners.ParentRunner.run(ParentRunner.java:300) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) Caused by: java.lang.ClassNotFoundException: org.mybatis.spring.SqlSessionFactoryBean.class at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) at org.springframework.util.ClassUtils.forName(ClassUtils.java:260) at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:416) at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1296) at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1267) ... 32 more 提示找不到的类是SqlSessionFactoryBean.class,但是下图可以看到已经导入的jar包下有这个类 啊![图片说明](https://img-ask.csdn.net/upload/201604/21/1461208942_696875.png)

请教一个Java 问题,求答案

ava.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcDriver at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown Source) at DataLink.<init>(DataLink.java:17) at DataFrame.actionPerformed(DataFrame.java:62) at java.awt.Button.processActionEvent(Unknown Source) at java.awt.Button.processEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.EventQueue.dispatchEventImpl(Unknown Source) at java.awt.EventQueue.access$500(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue$4.run(Unknown Source) at java.awt.EventQueue$4.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source)

eclipse写java查询数据的代码,ResultSet 报错 java.lang.NullPointerException?

eclipse+mysql5.7版本。<br> 报空指针错误。<br> 但是为啥会报错?<br> 用statement的时候就没有报错,学用preparestatement的时候就报错了。<br> 这是为什么? <br><br> ```java import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.Scanner; import java.sql.PreparedStatement; public class test { private static final String URL = "jdbc:mysql://localhost:3307/student"; private static final String USERNAME = "root"; private static final String PWD = "19990210"; public static void query() { Connection connection = null; PreparedStatement pstmt = null; ResultSet rs = null ; try { // a.导入驱动,加载具体的驱动类 Class.forName("com.mysql.jdbc.Driver");// 加载具体的驱动类 // b.与数据库建立连接 connection = DriverManager.getConnection(URL, USERNAME, PWD); // c.发送sql,执行【查】 Scanner input= new Scanner(System.in); System.out.println("请输入用户名:"); String name = input.nextLine() ; System.out.println("请输入年龄:"); String age = input.nextLine() ; String sql = "select count(*) from stuinfo where name= ? and age =?"; pstmt = connection.prepareStatement(sql); pstmt.setString(1, name); pstmt.setString(2, age); int count = -1; try { if(rs.next()) { count = rs.getInt(1) ; } } catch (Exception e) { e.printStackTrace(); } if(count>0) { System.out.println("登陆成功!"); }else { System.out.println("登陆失败!"); } } catch (ClassNotFoundException e) { System.out.println("111"); e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } catch(Exception e) { e.printStackTrace(); } finally { try { if(rs!=null) rs.close(); if(pstmt!=null) pstmt.close();// 对象.方法 if(connection!=null)connection.close(); }catch(SQLException e) { e.printStackTrace(); }catch(Exception e) { e.printStackTrace(); } } } public static void main(String[] args) { query() ; } } ``` <br><br> ![报错](https://img-ask.csdn.net/upload/202004/12/1586685955_71044.png)

启动hive时报错Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;)V

``` Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;)V at org.apache.hadoop.conf.Configuration.set(Configuration.java:1357) at org.apache.hadoop.conf.Configuration.set(Configuration.java:1338) at org.apache.hadoop.mapred.JobConf.setJar(JobConf.java:536) at org.apache.hadoop.mapred.JobConf.setJarByClass(JobConf.java:554) at org.apache.hadoop.mapred.JobConf.<init>(JobConf.java:448) at org.apache.hadoop.hive.conf.HiveConf.initialize(HiveConf.java:5141) at org.apache.hadoop.hive.conf.HiveConf.<init>(HiveConf.java:5099) at org.apache.hadoop.hive.common.LogUtils.initHiveLog4jCommon(LogUtils.java:97) at org.apache.hadoop.hive.common.LogUtils.initHiveLog4j(LogUtils.java:81) at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:699) at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:683) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.hadoop.util.RunJar.run(RunJar.java:323) at org.apache.hadoop.util.RunJar.main(RunJar.java:236) ```

java.lang.NullPointerException--at com.alibaba.druid.pool.DruidPooledConnection.prepareStatement

使用druid封装了一下,传入数据库连接信息和sql语句进行执行,但偶尔报错,没找到规律,请大神们帮看看是什么原因? 相关网上的资料也按照配置过,问题还没没有得到解决 druid 连接池 close connection error问题通过配置testOnBorrow=true暂未重现 以下是报错信息,这个问题一直没得到解决 ``` 返回结果-------------:1 系统异常了CONN:com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@1b4197e1 系统异常了SQL:insert into ZFGL.BILLS_DETAIL ( f_timestamp , BCODE , BILLNO , BILLSDETAILGUID , BNAME , ECODE , ECONOMYGUID , ENAME , ENTERPRISEGUID , FUNCTIONGUID , GOVECOGUID , GOVKCODE , GOVKNAME , GUID , INAME , KCODE , KNAME , PAYMODCODE , PAYMODID , PAYMODNAME , PROGRAMCODE , PROGRAMGUID , PROGRAMTYPECODE , PROGRAMTYPEID , PROGRAMTYPENAME , RELAID , RESOURCECODE , RESOURCEGUID , TOTALMONEY , TZMC , YEAR) values ( to_timestamp('2019-03-12 11:43:16.637953','yyyy-mm-dd hh24:mi:ss.ff6') ,'2040601' ,'2019010001000004' ,'' ,'行XXXXX' ,'010001' ,'C3146047304548D1AAD0066E62595F52' ,'克XXXX' ,'037A71055FCD4FF882F7E575120FEEBD' ,'' ,'' ,'' ,'' ,'ED494B52F7B249C5B6E24F52D92E12E7' ,'公用支出' ,'30XXXX' ,'福XXXX' ,'12' ,'870517B306F94DFF84305120BCDC26B6' ,'财政授权支付' ,'00019992' ,'34772B4128B14606982C532BCAB0316D' ,'01' ,'2F0DF49684EE465CBC28FD1CC908F140' ,'基本支XX 76651498380024E0530A2CA82B62C8' ,'11' ,'7EF59F8C9FF7424989F4E3ED61254B4F' ,'802.811223般公共XXXX' 19' ) java.lang.NullPointerException at com.alibaba.druid.pool.DruidPooledConnection.prepareStatement(DruidPooledConnection.java:350) at com.yicaida.dal.serviceimpl.DynamicConnServiceImpl.execSql(DynamicConnServiceImpl.java:295) at com.yicaida.dx.serviceimpl.DxServiceImpl.runApiNow(DxServiceImpl.java:332) at com.alibaba.dubbo.common.bytecode.Wrapper7.invokeMethod(Wrapper7.java) at com.alibaba.dubbo.rpc.proxy.javassist.JavassistProxyFactory$1.doInvoke(JavassistProxyFactory.java:46) at com.alibaba.dubbo.rpc.proxy.AbstractProxyInvoker.invoke(AbstractProxyInvoker.java:72) at com.alibaba.dubbo.rpc.protocol.InvokerWrapper.invoke(InvokerWrapper.java:53) at com.alibaba.dubbo.rpc.filter.ExceptionFilter.invoke(ExceptionFilter.java:64) at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91) at com.alibaba.dubbo.monitor.support.MonitorFilter.invoke(MonitorFilter.java:75) at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91) at com.alibaba.dubbo.rpc.filter.TimeoutFilter.invoke(TimeoutFilter.java:42) at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91) at com.alibaba.dubbo.rpc.protocol.dubbo.filter.TraceFilter.invoke(TraceFilter.java:78) at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91) at com.alibaba.dubbo.rpc.filter.ContextFilter.invoke(ContextFilter.java:60) at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91) at com.alibaba.dubbo.rpc.filter.GenericFilter.invoke(GenericFilter.java:112) at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91) at com.alibaba.dubbo.rpc.filter.ClassLoaderFilter.invoke(ClassLoaderFilter.java:38) at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91) at com.alibaba.dubbo.rpc.filter.EchoFilter.invoke(EchoFilter.java:38) at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91) at com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol$1.reply(DubboProtocol.java:108) at com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.handleRequest(HeaderExchangeHandler.java:84) at com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.received(HeaderExchangeHandler.java:170) at com.alibaba.dubbo.remoting.transport.DecodeHandler.received(DecodeHandler.java:52) at com.alibaba.dubbo.remoting.transport.dispatcher.ChannelEventRunnable.run(ChannelEventRunnable.java:82) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) ``` 源代码如下 ``` public Integer execSql(DBInfoBean dbinfo, String sqlstr) { int result; PreparedStatement ps = null; try { conn = getConn(dbinfo); if (conn.isClosed() || conn == null) { conn = getConn(dbinfo); } ps = conn.prepareStatement(sqlstr); result = ps.executeUpdate(); } catch (Exception err) { System.out.println("系统异常了CONN:" + conn); System.out.println("系统异常了SQL:" + sqlstr); err.printStackTrace(); result = -1; } finally { if (ps != null) { try { ps.close(); } catch (SQLException e) { e.printStackTrace(); result = -1; } } close(); } System.out.println("返回结果-------------:" + result); return result; } ```

java.lang.NoClassDefFoundError

package hx.nan.JDBCUtils; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.ResourceBundle; public class DBConnection { public static String URL; public static String USERNAME; public static String PASSWORD; public static String DRIVER; private DBConnection(){} static{ ResourceBundle rb = ResourceBundle.getBundle("JDBCUtils.jdbc_config"); URL = rb.getString("URL"); USERNAME = rb.getString("USERNAME"); PASSWORD = rb.getString("PASSWORD"); DRIVER = rb.getString("DRIVER"); try { Class.forName(DRIVER); } catch (ClassNotFoundException e) { System.out.println("驱动加载失败"); e.printStackTrace(); } } public static Connection getConnection(){ Connection con = null; try { con = DriverManager.getConnection(URL,USERNAME,PASSWORD); } catch (SQLException e) { e.printStackTrace(); System.out.println("获取数据库连接失败"); } return con; } public static void close(ResultSet rs,Statement state,Connection con){ try { if(rs!=null){ rs.close(); } state.close(); con.close(); } catch (SQLException e) { e.printStackTrace(); } } } java.lang.NoClassDefFoundError: Could not initialize class hx.nan.JDBCUtils.DBConnection hx.nan.JDBCUtils.JdbcTemplete.update(JdbcTemplete.java:30) hx.nan.Dao.UserDaoImp.add(UserDaoImp.java:33) hx.nan.action.RegisterAction.doPost(RegisterAction.java:29) javax.servlet.http.HttpServlet.service(HttpServlet.java:648) javax.servlet.http.HttpServlet.service(HttpServlet.java:729) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 如果没有静态块的话不会报错,正常运行,这是怎么回事?而且try catch也没有捕获到异常

java.lang.RuntimeException ,找不到配置的Action类

applicationContext.xml文件中配置scheduleAction了啊!struts.xml文件中“初始化当前用户显示所有日程列表”的action也是用的scheduleAction,为什么“查询日程列表”的action就找不到这个类呢? ---------------------- [img]http://dl.iteye.com/upload/attachment/570153/cb780579-43b0-3273-8efe-ee6ea4e7cb92.png[/img] --------------------- [img]http://dl.iteye.com/upload/attachment/570155/1cb500de-6251-3b01-bb08-28bd26c01d9d.png[/img] ---------------------- [img]http://dl.iteye.com/upload/attachment/570157/b0b8b53a-ce5a-31e4-b351-90cb8f96b835.png[/img] java.lang.RuntimeException: Invalid action class configuration that references an unknown class named [[color=red]scheduleAction[/color]] org.apache.struts2.convention.ConventionsServiceImpl.determineResultPath(ConventionsServiceImpl.java:100) org.apache.struts2.convention.ConventionUnknownHandler.determinePath(ConventionUnknownHandler.java:385) org.apache.struts2.convention.ConventionUnknownHandler.handleUnknownResult(ConventionUnknownHandler.java:274) com.opensymphony.xwork2.DefaultUnknownHandlerManager.handleUnknownResult(DefaultUnknownHandlerManager.java:76) com.opensymphony.xwork2.DefaultActionInvocation.createResult(DefaultActionInvocation.java:215) com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:356) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:266) com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:165) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:252) org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:179) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:235) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:89) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:130) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:126) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:165) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:179) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52) org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488) org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77) org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91) root cause java.lang.ClassNotFoundException: scheduleAction org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1358) org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204) org.apache.struts2.util.ClassLoaderUtils.loadClass(ClassLoaderUtils.java:111) org.apache.struts2.convention.ConventionsServiceImpl.determineResultPath(ConventionsServiceImpl.java:98) org.apache.struts2.convention.ConventionUnknownHandler.determinePath(ConventionUnknownHandler.java:385) org.apache.struts2.convention.ConventionUnknownHandler.handleUnknownResult(ConventionUnknownHandler.java:274) com.opensymphony.xwork2.DefaultUnknownHandlerManager.handleUnknownResult(DefaultUnknownHandlerManager.java:76) com.opensymphony.xwork2.DefaultActionInvocation.createResult(DefaultActionInvocation.java:215) com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:356) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:266) com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:165) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:252) org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:179) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:235) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:89) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:130) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:126) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:165) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:179) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52) org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488) org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77) org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)

2019 Python开发者日-培训

2019 Python开发者日-培训

150讲轻松搞定Python网络爬虫

150讲轻松搞定Python网络爬虫

设计模式(JAVA语言实现)--20种设计模式附带源码

设计模式(JAVA语言实现)--20种设计模式附带源码

YOLOv3目标检测实战:训练自己的数据集

YOLOv3目标检测实战:训练自己的数据集

java后台+微信小程序 实现完整的点餐系统

java后台+微信小程序 实现完整的点餐系统

三个项目玩转深度学习(附1G源码)

三个项目玩转深度学习(附1G源码)

初级玩转Linux+Ubuntu(嵌入式开发基础课程)

初级玩转Linux+Ubuntu(嵌入式开发基础课程)

2019 AI开发者大会

2019 AI开发者大会

玩转Linux:常用命令实例指南

玩转Linux:常用命令实例指南

一学即懂的计算机视觉(第一季)

一学即懂的计算机视觉(第一季)

4小时玩转微信小程序——基础入门与微信支付实战

4小时玩转微信小程序——基础入门与微信支付实战

Git 实用技巧

Git 实用技巧

Python数据清洗实战入门

Python数据清洗实战入门

使用TensorFlow+keras快速构建图像分类模型

使用TensorFlow+keras快速构建图像分类模型

实用主义学Python(小白也容易上手的Python实用案例)

实用主义学Python(小白也容易上手的Python实用案例)

程序员的算法通关课:知己知彼(第一季)

程序员的算法通关课:知己知彼(第一季)

MySQL数据库从入门到实战应用

MySQL数据库从入门到实战应用

机器学习初学者必会的案例精讲

机器学习初学者必会的案例精讲

手把手实现Java图书管理系统(附源码)

手把手实现Java图书管理系统(附源码)

极简JAVA学习营第四期(报名以后加助教微信:eduxy-1)

极简JAVA学习营第四期(报名以后加助教微信:eduxy-1)

.net core快速开发框架

.net core快速开发框架

玩转Python-Python3基础入门

玩转Python-Python3基础入门

Python数据挖掘简易入门

Python数据挖掘简易入门

微信公众平台开发入门

微信公众平台开发入门

程序员的兼职技能课

程序员的兼职技能课

Windows版YOLOv4目标检测实战:训练自己的数据集

Windows版YOLOv4目标检测实战:训练自己的数据集

HoloLens2开发入门教程

HoloLens2开发入门教程

微信小程序开发实战

微信小程序开发实战

Java8零基础入门视频教程

Java8零基础入门视频教程

相关热词 c# 开发接口 c# 中方法上面的限制 c# java 时间戳 c#单元测试入门 c# 数组转化成文本 c#实体类主外键关系设置 c# 子函数 局部 c#窗口位置设置 c# list 查询 c# 事件 执行顺序
立即提问