作者:尤天asoka | 来源:互联网 | 2018-04-26 10:01
Class.forName("com.mysql.jdbc.Driver");ctDriverManager.getConnection("jdbc:mysql:localhost:3306test1","root","wenhao");smct.createStatement();rssm.executeQuery("select*fromtest");try{ps
mysqljava数据库没数据数据库连接
Class.forName("com.mysql.jdbc.Driver"); ct=DriverManager.getConnection("jdbc:mysql://localhost:3306/test1","root","wenhao"); sm=ct.createStatement(); rs=sm.executeQuery("select *from test"); try { ps=ct.prepareStatement("insert test values(14,'aaa')"); System.out.print("插入成功"); } catch (Exception e) { // TODO Auto-generated catch block System.out.print("插入失败"); }