activejdbc

基于 Java 的 Active Record 开源项目

狂风中的少年 提交于 2020-03-01 05:41:33
Active Record 是什么?也许很多做 Java 的朋友并没有听说过这个概念,但它确实很早就已经出现了。 确切地说,应该是在 2003 年,由世界大师级人物 Martin Fowler(马丁 · 福勒)在他写的一本叫做《企业应用架构模式》书里就描述过这个模式。不可否认,马丁是软件架构的泰斗,他写的每本书,我都买过,虽然很多内容我还看不懂,但每次阅读都有新的认识,虽然这些文字已经很陈旧了。 如果您想了解关于 Active Record 的权威定义,可以点击下面的维基百科地址: http://zh.wikipedia.org/wiki/Active_Record 当然,如果您想听到更通俗易懂的言语,我可以试着描述一下: 它是面向领域对象的设计模式 它为每个领域对象提供一组 CRUD 方法 以上提到的 领域对象 实际上就是我们经常说的 Entity (实体)。 Active Record 模式最早是在 Ruby on Rails(RoR)里取得了最佳实践,然后其它开发语言开始效仿,比如:PHP、Python 等,当然 Java 也不例外。 这几天我收集了几款基于 Java 的 Active Record 开源项目,这些项目都非常优秀,让我收获良多、受益匪浅!所以我忍不住想与大家分享一下我的学习心得与体会。 需要申明的是:本文仅代表个人看法,本人仅站在使用者的角度来体验这些产品

Tomcat + ActiveJDBC: open/close connection using servlet filter?

佐手、 提交于 2020-01-17 05:51:04
问题 My web application uses ActiveJDBC. This ORM framework requires to open new DB connection with every new thread (and of course close it when the thread finishes). I am wondering if the best way to achieve this is to use a Web Filter. if this is the case, where do I call Base.open() ? the options are init() or doFilter() . also, if I plan to call Base.close() in destroy() , I need to know that indeed destroy() is always called at the thread termination, whether it is normal or abnormal. EDIT:

Cannot open a new connection because existing connection is still on current thread - ActiveJDBC

你说的曾经没有我的故事 提交于 2019-12-13 03:45:22
问题 I'm getting this error Cannot open a new connection because existing connection is still on current thread after a while. I think the error is pretty self explanatory. My code is this: String mySQLUrl = "jdbc:postgresql://" + dataLayer.PostgreSQL_Host + "/" + dataLayer.PostgreSQL_Database; Base.open("org.postgresql.Driver", mySQLUrl, dataLayer.getPostgreSQLUser(), dataLayer.getPostgreSQLPassword()); In order to avoid that error, i would like to create a connection factory, but to accomplish

java.lang.IllegalArgumentException: number of arguments must be even at org.javalite.activejdbc.Model.set

一曲冷凌霜 提交于 2019-12-12 03:40:01
问题 The request body: request.body {"username":"kkk.k999@gmail.com","userImage":"https://lh3.googleusercontent.com/-XdUIqdMkffA/AAAAAAAAAAI/AAAAAAAAAAA/4252rscbv5M/photo.jpg?sz=50","role":"ROLE_USER","token":"ya29.GmIYBNhh5zs2Cpq1UI2iVzdxDvMVf2x8ggpEgM9Jvk51f5FOGodUZINrabY6K9Mhn6L82XpUhOyh5uIPhLZkAjIqS1hBu7un9QhMzRW35 RJM5ZwFozlBIuuxFRP4Y5xsTtdPGw"} Error while Saving to Db: @Override public void saveUserInfo(Request request) { Base.open("com.mysql.jdbc.Driver", "jdbc:mysql://localhost/47seconds"

轻量级ORM框架ActiveJDBC介绍

别等时光非礼了梦想. 提交于 2019-12-03 04:33:40
在 OSChina 上看到这款开源轻量级的ORM框架,看了下例子,感觉非常小巧轻量简单。 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",

Can't get activejdbc working?

社会主义新天地 提交于 2019-12-02 12:09:28
问题 I have the following classes: package models; public class Test extends activejdbc.Model { } : and : import activejdbc.*; import models.Test; public class ActiveJdbc { public static void main(String args []) throws Exception { System.out.println("starting..."); test(); } public static void test() throws Exception { activejdbc.Base.open("org.h2.Driver", "jdbc:h2:tcp://localhost/~/test", "sa", ""); models.Test t = models.Test.findFirst("id = ??",1); String s = t.get("name").toString(); System

Can't get activejdbc working?

情到浓时终转凉″ 提交于 2019-12-02 07:11:10
I have the following classes: package models; public class Test extends activejdbc.Model { } : and : import activejdbc.*; import models.Test; public class ActiveJdbc { public static void main(String args []) throws Exception { System.out.println("starting..."); test(); } public static void test() throws Exception { activejdbc.Base.open("org.h2.Driver", "jdbc:h2:tcp://localhost/~/test", "sa", ""); models.Test t = models.Test.findFirst("id = ??",1); String s = t.get("name").toString(); System.out.println(s); } } : but when I run it with : java -cp .;../lib/h2.jar;../lib/activejdbc.jar;../lib