ActiveJDBC 是一个快速和轻量级的 Java 的 ORM 小型框架,语法简单易于理解,同时支持多数据库链接。ActiveJDBC 的文档非常完善。基于以下原则设计:
下面是一个简单的 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(); } }