English 中文(简体)
jj2se 应用最佳做法
原标题:j2se application best practice
  • 时间:2012-05-25 06:24:04
  •  标签:
  • java
  • jdbc

i 想要建立一个简单的 CROUD 控制台应用程序,由需要使用 CROUD 方法的10-20 类组成。我不想每次在需要 db 访问的每一种方法中创建连接。也许将所有创建部件都放入单独的单吨类?
任何想法、如何构建这种应用的最佳做法?

最佳回答

仅一个教程就足够学习 < a href=>" "http://balusc.blogspot.com/2008/07/dao-tutor-tutor-data-layer.html" rel="no follow" > 如何设计 DAO

问题回答

使用Netbeans JPA向导:

  • Entity Classes from Database (Check the Adding Entities part of this)
  • JPA Controller classes from Entities (Small sample)

不需要处理连接 。

创建基础类, 以所有功能作为分隔法。 例如, 如下 。

连接获取连接 - 返回连接对象

无效关闭() - 关闭连接

类似每个功能的这个执行方法。 将您的操作类扩展至这个基级, 并调用所需的功能 。

ex :

 public class Insert extends Base {

// call the rquired functions

}

需要时,您可以模拟一些变量,如驱动器名、 URL、 用户名、 密码等,



上一篇:
下一篇:


相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签