@RemoteProxy and DB design

103 阅读1分钟

·# Created by Wang, Jerry on Nov 13, 2015

DWR Annotations

DWR annotations can be used as a replacement as well as in conjunction with dwr.xml.
Annotation support was written by Maik Schreiber.

Setup

To use DWR with annotations you need to specify a different DWR controller servlet in yourweb.xml:

<servlet>
  <description>DWR controller servlet</description>
  <servlet-name>DWR controller servlet</servlet-name>
  <servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
  <init-param>
    <param-name>classes</param-name>
    <param-value>
      com.example.RemoteFunctions,
      com.example.RemoteBean
    </param-value>
  </init-param>
</servlet>

Remote Class Access

To make a simple class available for remote access, use the @RemoteProxy and@RemoteMethod annotations:

@RemoteProxy
public class RemoteFunctions {
    @RemoteMethod
    public int calculateFoo() {
       return 42;
    }
}

link: hsqldb.org/doc/guide/c…
read from script file
Launch demo database
lock just a file, you have to delete this file manually to work on the db.
launch DB tool -
Failed to load preferences. Proceeding with defaults:

java.sql.SQLException: The database is already in use by another process: lockFile: org.hsqldb.persist.LockFile@8c306d86[file =/root/DemoDB/demoDB.lck, exists=true, locked=false, valid=false, ] method: checkHeartbeat read: 2015-11-13 09:25:38.001 heartbeat - read: -4168 ms.
at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
at org.hsqldb.jdbc.jdbcConnection.(Unknown Source)
at org.hsqldb.jdbcDriver.getConnection(Unknown Source)
at org.hsqldb.jdbcDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at org.hsqldb.util.ConnectionDialogSwing.createConnection(Unknown Source)
at org.hsqldb.util.DatabaseManagerSwing.main(Unknown Source)

www.hsqldb.org/doc/1.8/gui…
要获取更多Jerry的原创文章,请关注公众号"汪子熙":