看不懂的报错
代码 package com.imooc.jdbc; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import org.junit.Test; import com.imooc.jdbc.util.JDBCUtils; import com.mchange.v2.c3p0.ComboPooledDataSource; public class Demo3 { @Test public void demo1() { Connection conn = null; PreparedStatement pstm = null; ResultSet rs = null; try{ //创建连接池 ComboPooledDataSource dataSource = new ComboPooledDataSource(); //设置连接池参数 dataSource.setDriverClass("com.mysql.jdbc.Driver"); dataSource.setJdbcUrl("jdbc:mysql://localhost:3306/imooc_test"); dataSource.setUser("root"); dataSource.setPassword("password"); dataSource.setMaxPoolSize(20); dataSource.setInitialPoolSize(3); //获得连接 conn = dataSource.getConnection(); String sql = "SELECT * FROM course"; pstm = conn.prepareStatement(sql); rs = pstm.executeQuery(); while(rs.next()) { System.out.println("id = "+rs.getInt("id")+" "+"name = "+rs.getString("name")+" "+"category = "+rs.getString("category")+" "+"desp = "+rs.getString("desp")+" "+"createTime = "+rs.getString("createTime")+" "); } }catch(Exception e) { e.printStackTrace(); }finally { JDBCUtils.release(pstm, conn, rs); } } } sql
USE imooc_test; CREATE TABLE IF NOT EXISTS course( `id`INT UNSIGNED NOT NULL KEY AUTO_INCREMENT COMMENT"课程编号", `name`VARCHAR(20) NOT NULL COMMENT"课程名称", `category`VARCHAR(20) NOT NULL COMMENT"所属方向", `desp`VARCHAR(30)NOT NULL COMMENT"课程描述", `createtime`DATETIME NOT NULL COMMENT"创建时间" )ENGINE=innoDB CHARSET=utf8; INSERT course VALUES(NULL,"JAVA零基础","JAVA","JAVA基础语法",now()), (NULL,"JAVA Web","Java","JSP和Servlet",now()), (NULL,"前端小白","前端","HTML/CSS/JS",now());
报错截图
文字
java.lang.Exception: No tests found matching [{ExactMatcher:fDisplayName=demo1], {ExactMatcher:fDisplayName=demo1(com.imooc.jdbc.Demo3)], {LeadingIdentifierMatcher:fClassName=com.imooc.jdbc.Demo3,fLeadingIdentifier=demo1]] from org.junit.internal.requests.ClassRequest@4fca772d
at org.junit.internal.requests.FilterRequest.getRunner(FilterRequest.java:35)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createFilteredTest(JUnit4TestLoader.java:83)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:74)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:49)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:525)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)
工具
正在回答 回答被采纳积分+1
相似问题
登录后可查看更多问答,登录/注册
- 参与学习 人
- 提交作业 357 份
- 解答问题 8016 个
本阶段将带你学习MySQL数据库,JDBC接口,MyBatis框架等,带你掌握的数据的存放和管理。
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星