2013年9月19日
摘要: try { //加载驱动 Class.forName("com.mysql.jdbc.Driver"); String url="jdbc:mysql://127.0.0.1:3306/test"; //通过DriverManager获取连接 Connection conn=DriverManager.getConnection(url,"root","hello"); System.out.println("conn:"+conn); //准备操作数据库 //Statement:用于执行静态SQL语句并返回它所生产结果的对象 Statement stm=conn.createStatement(); String sql="insert into test.new_table(t1,t2) values('t11','t22');"; Boolean ret =stm.execute(sql); conn.close(); } catch (Exception e) { // TODO: handle exception e.printStackTrac 阅读全文
posted @ 2013-09-19 11:32 上校 阅读(5006) 评论(0) 推荐(1)