jnlp的SingleInstanse

//实现SingleInstanceListener接口
class SISListener implements SingleInstanceListener
{
    public void newActivation(String[] params)
    {
        //处理传入参数
    }
}
//获取服务
SingleInstanceService sis; 
try
{ 
    sis = (SingleInstanceService)ServiceManager.lookup("javax.jnlp.SingleInstanceService");
} 
catch (UnavailableServiceException e) 
{ 
    sis=null; 
}
//程序启动时注册SingleInstanceListener
SISListener sisL = new SISListener();
sis.addSingleInstanceListener(sisL);
//程序退出时移除SingleInstanceListener
sis.removeSingleInstanceListener(sisL);
System.exit(0);

Applet自签名

1、修改Applet主Jar包的Manifest文件,添加下面几行,然后重新打包

Application-Name: AppletTest
Implementation-version: 1.0
Application-Library-Allowable-Codebase: *
Permissions: sandbox
Caller-Allowable-Codebase: * localhost 127.0.0.1

2、生成keystore及key

#生成私钥
keytool -validity 10000 -genkey -alias xxxxxx -keypass xxxxxx -storepass xxxxxx -keystore xxxxxx.jks -dname "CN=(R&D),O=(ATS),C=(CN)" -keyalg RSA

导出证书

#证书DER格式
keytool -exportcert -alias xxxxxx -keypass xxxxxx -keystore xxxxxx.jks -storepass xxxxxx -file xxxxxx.der
#证书PEM格式
keytool -exportcert -alias xxxxxx -keypass xxxxxx -keystore xxxxxx.jks -storepass xxxxxx -rfc -file xxxxxx.pem

枚举证书

keytool -list -keystore xxxxxx.jks 

3、签名

jarsigner -keystore xxxxxx.jks -storepass xxxxxx -keypass xxxxxx xxxxxx.jar xxxxxx

4、验证

JARsigner -verbose -verify  xxxxxx.jar

5、信任签名证书,下面两种方式用一种就好了
5.1、导入CA证书(按用OS登录户全局,自签名Jar)

#下面的方式,与java控制面板导入证书效果相同

#win7
keytool -import -trustcacerts -keystore "%userprofile%\AppData\LocalLow\Sun\Java\Deployment\security\trusted.certs" -alias "" -file XXXXXX.cer -storepass "" -noprompt

#winxp
keytool -import -trustcacerts -keystore "%APPDATA%\Sun\Java\Deployment\security\trusted.certs" -alias "" -file XXXXXX.cer -storepass "" -noprompt

5.2、导入CA证书(按JDR/JRE全局,自签名Jar)

keytool -import -trustcacerts -file XXXXXX.der -alias NMyCA1024 -keystore %JRE_HOME%\lib\security\cacerts -storepass changeit

6、如果自签名证书还是不行的话
到java控制面板,安全中,把你的网站添加到信任列表就好了。

Hibernate主键

increment
It generates identifiers of type long, short or int that are unique only when no other process is inserting data into the same table. It should not the used in the clustered environment.

identity
It supports identity columns in DB2, MySQL, MS SQL Server, Sybase and HypersonicSQL. The returned identifier is of type long, short or int.

sequence
The sequence generator uses a sequence in DB2, PostgreSQL, Oracle, SAP DB, McKoi or a generator in Interbase. The returned identifier is of type long, short or int

hilo
The hilo generator uses a hi/lo algorithm to efficiently generate identifiers of type long, short or int, given a table and column (by default hibernate_unique_key and next_hi respectively) as a source of hi values. The hi/lo algorithm generates identifiers that are unique only for a particular database. Do not use this generator with connections enlisted with JTA or with a user-supplied connection.

seqhilo
The seqhilo generator uses a hi/lo algorithm to efficiently generate identifiers of type long, short or int, given a named database sequence.

uuid
The uuid generator uses a 128-bit UUID algorithm to generate identifiers of type string, unique within a network (the IP address is used). The UUID is encoded as a string of hexadecimal digits of length 32.

guid
It uses a database-generated GUID string on MS SQL Server and MySQL.

native
It picks identity, sequence or hilo depending upon the capabilities of the underlying database.

assigned
lets the application to assign an identifier to the object before save() is called. This is the default strategy if no element is specified.

select
retrieves a primary key assigned by a database trigger by selecting the row by some unique key and retrieving the primary key value.

foreign
uses the identifier of another associated object. Usually used in conjunction with a primary key association.

Jar包签名

1、生成keystore及key

#生成私钥
keytool -validity 10000 -genkey -alias xxxxxx -keypass xxxxxx -storepass xxxxxx -keystore xxxxxx.jks -dname "CN=(R&D),O=(ATS),C=(CN)" -keyalg RSA

导出证书

#证书DER格式
keytool -exportcert -alias xxxxxx -keypass xxxxxx -keystore xxxxxx.jks -storepass xxxxxx -file xxxxxx.der
#证书PEM格式
keytool -exportcert -alias xxxxxx -keypass xxxxxx -keystore xxxxxx.jks -storepass xxxxxx -rfc -file xxxxxx.pem

枚举证书

keytool -list -keystore xxxxxx.jks 

2、签名

jarsigner -keystore xxxxxx.jks -storepass xxxxxx -keypass xxxxxx xxxxxx.jar xxxxxx

3、验证

JARsigner -verbose -verify  xxxxxx.jar

C#调用cdll指针参数处理

1、API声明(包括**参数)

int GetTheLastErrorA(char **pcError);
int GetTheLastErrorW(wchar_t **pwError);

2、C#代码

using System.Runtime.InteropServices;

[DllImport("StringAW.dll", CallingConvention = CallingConvention.Winapi, 
CharSet = CharSet.Ansi, EntryPoint = "GetTheLastErrorA")]
extern static int GetTheLastErrorA(ref IntPtr a);

[DllImport("StringAW.dll", CallingConvention = CallingConvention.Winapi, 
CharSet = CharSet.Auto, EntryPoint = "GetTheLastErrorW")]
extern static int GetTheLastErrorW(ref IntPtr w);

IntPtr a = IntPtr.Zero;
GetTheLastErrorA(ref a);
String sa = Marshal.PtrToStringAnsi(a);
MessageBox.Show(sa);

IntPtr w = IntPtr.Zero;
GetTheLastErrorW(ref w);
String sw = Marshal.PtrToStringUni(w);
MessageBox.Show(sw);

Table删除所有行

1.用jquery的话,还是很简单的

$("#tbid").empty();

2.但如果要保留前几行,比如前两行的话

function ClearTableData(tbid){
	var rows = document.getElementById(tbid).getElementsByTagName('tr');
	if(rows==null || rows.length<3)return;
	for(var i=2;i<rows.length;i++)
	{
		rows[i].parentNode.removeChild(rows[i]);
	}
}

JQuery动态加载Table

用于在同一Table显示两级内容
点击一次,会用ajax从服务器加载json数据,并添加到该行下面
再点击一次,会利用name属性,删除对应的行

function ExpendPatient(srow,pid){
    var imgc = "#p"+pid+"imgc";
    var imgo = "#p"+pid+"imgo";

    if($(imgo).is(":visible"))
    {
        $(imgo).hide();
        $(imgc).show();
        
        delrows = document.getElementsByName("p"+pid+"study");
        for (var i=0;i<delrows.length;i++) 
        {
            delrows&#91;i&#93;.parentNode.removeChild(delrows&#91;i&#93;);
        }
        return;
    }
    $(imgc).hide();
    $(imgo).show();
    
    aurl="xxxxxxxxxxxx?patPk="+pid;
    try
    {
        $.ajax({
          url: aurl,
          dataType: 'json',
          error: function(XMLHttpRequest, textStatus, errorThrown){
            alert('错误原因 ' + textStatus);
            alert('错误堆栈 ' + errorThrown);
            alert('返回字符 ' + XMLHttpRequest.responseText);
          },
          success: function(data) {
              $.each(data,function(i,record){
                  r = '<tr height="30" name="p'+pid+'study" onclick="DoSomeThing(this,'+record&#91;"pk"&#93;+');"&#93;';
                  r += '<td></td>';
                  r += '<td>'+record["a"]+'</td>';
                  r += '<td>'+record["b"]+'</td>';
                  r += '<td>'+record["c"]+'</td>';
                  r += '<td>'+record["d"]+'</td>';
                  r += '<td>'+record["e"]+'</td>';
                  r += '<td>'+record["f"]+'</td>';
                  r += "</tr>";
                  $(srow).after(r);
              });
          }
        });
    }
    catch(e)
    {
        alert(e);
    }
}