jar包加了的哈,数据库connection连接也没写错,运行起来代码也没有报错,代码如下
@testpublic void zengtest() { connection conn = null; statement sta = null; try{ class.forname(com.mysql.jdbc.driver); conn = drivermanager.getconnection(jdbc:mysql://localhost:3306/d-7test, root, cailikun); sta = conn.createstatement(); //增加数据的sql: string sql = insert into `uesr`(name) values('小蔡') ; sta.executeupdate(sql); } catch(exception e){ e.printstacktrace(); }finally{ //最后执行两次“事” try{if(sta!=null){ sta.close(); } }catch(exception e){ e.printstacktrace(); }finally{ try{if(conn!=null){ conn.close(); } }catch(exception e){ e.printstacktrace(); } } }}
运行起来表格里什么都没有