try {// if the lock was null, anthor program was locking the file.
lock=new FileOutputStream(new File(lockPath)).getChannel().tryLock()
} catch (Exception e) {
return false
}
// do not close stream or file will be unlocked
return lock==null
}
可以通过其它方法来实现:1:如果没用框架,直接加密、解密即可
2:如果用hibernate之类,可以绕过Configuration,读取Hibernate配置文件解密后再连接数据库
3:考虑集群影响
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)