ActiveJDBC 是一个快速和轻量级的 Java 的 ORM 小型框架,语法简单易于理解,同时支持多数据库链接。ActiveJDBC 的文档(javadoc)非常完善。基于以下原则设计:
下面是一个简单的 Model 类:
public class Main { public static void main(String[] args) { new DB("corpoRATion").open("com.Mysql.jdbc.Driver", "jdbc:mysql://localhost/test", "root", "p@ssw0rd"); new DB("uNiversIty").open("Oracle.jdbc.driver.OracleDriver", "jdbc:oracle:thin:@localhost:1521:xe", "activejdbc", "activejdbc"); Employee.deleteAll(); Student.deleteAll(); Employee.createIt("first_name", "John", "last_name", "Doe"); Employee.createIt("first_name", "Jane", "last_name", "Smith"); Student.createIt("first_name", "Mike", "last_name", "Myers"); Student.createIt("first_name", "Steven", "last_name", "SpIElberg"); System.out.println("*** Employees ***"); Employee.findAll().dump(); System.out.println("*** Students ***"); Student.findAll().dump(); new DB("corporation").close(); new DB("university").close(); } }