Spring框架入门HelloWorld :http://www.importnew.com/13246.html (iteye 唐 博客,跟我学Sprint)
Spring 框架下载地址:http://repo.spring.io/release/org/springframework/spring/
Class.forName方法,此方法含义是:加载参数指定的类,并且初始化它。
// TODO Auto-generated method stub //声明connection 对象 Connection con; //驱动程序名 String driver = "com.mysql.jdbc.Driver"; //URL指向要访问的数据库名 String url = "jdbc:mysql://localhost:3306/sqltestdb"; String user = "root"; String password = "123456"; try { //加载驱动程序 Class.forName((driver)); //1 .getConnection()方法连接MYSQL数据库; con = DriverManager.getConnection(url,user,password);
抽象类:抽象类不能实例化对象,类的其它功能仍然存在。抽象类只能被继承,才能被使用。在java中使用abstract 业定义抽象类;
/* 文件名 : Employee.java */public abstract class Employee{ private String name; private String address; private int number; public Employee(String name, String address, int number) { System.out.println("Constructing an Employee"); this.name = name; this.address = address; this.number = number; } public double computePay() { System.out.println("Inside Employee computePay"); return 0.0; } public void mailCheck() { System.out.println("Mailing a check to " + this.name + " " + this.address); }}