执行数据库的更新操作 Statement接口,通过Connection接口的createStatement()方法实例化,来操作数据库 public static final String DRIVER="org.gjt.mm.mysql.Driver";public static final String URL="jdbc:mysql://localhost:3306/newsql";public static final String USERNAME="root";public static void main(String[] args)throws Exception{ Connection conn=null; Statement statement=null; String sql="insert into newtable(name) values('ccw')"; try{ Class.forName(DRIVER); //加载驱动 }catch(ClassNotFoundException e){ e.printStackTrace() ; } conn=DriverManager.getConnection(URL,USERNAME,USERNAME); statement=conn.createStatement(); statement.executeUpdate(sql); try{ statement.close(); //先开后关闭,可以只关闭connection conn.close(); }catch(Exception e){ e.printStackTrace(); }}