2.導(dǎo)入jar包(例如,log4j-1.2.15.jar,slf4j-api-1.5.2.jar,slf4j-log4j12-1.5.0.jar)見附件:/Files/ZouYonghui/log4j.rar
3.在src目錄下編寫log.properties文件,里面包含日志所在位置,如下所示:









og4j.appender.logFile.MaxBackupIndexloWorld.log















PropertyConfigurator.configure("log4j.properties");
5.使用
如:
private static final Logger log = LoggerFactory.getLogger(HelloWorld.class);
。。。。。。
log.debug("hello");
Hibernate 默認(rèn)總共支持 13 種生成策略 :
1. increment 2. identity 3. sequence
4. hilo 5. seqhilo 6. uuid
7. uuid.hex 8. guid 9. native
10. assigned 11. select 12. foreign 13. sequence-identity
下面介紹幾個(gè)較為常用的策略 :
① identity [ 自然遞增 ]
支持 DB2,MySQL,SQL Server,Sybase 和HypersonicSQL 數(shù)據(jù)庫, 用于為 long 或 short 或 int 類型生成唯一標(biāo)識(shí)。它依賴于底層不同的數(shù)據(jù)庫,
與 Hibernate 和 程序員無關(guān)。
注解示例 :
@Id
@GenericGenerator(name = "idGenerator", strategy = "identity")
@GeneratedValue(generator = "idGenerator")
② sequence [ 序列 ]
支持 Oracle,DB2,PostgreSql,SAPDb 等數(shù)據(jù)庫,用于為 long 或 short 或 int 類型生成唯一標(biāo)識(shí)。它需要底層數(shù)據(jù)庫的支持,
并由數(shù)據(jù)庫來維護(hù)這個(gè) sequence 序列。
注解示例 :
@Id
@GenericGenerator(name = "idGenerator", strategy = "sequence",
parameters = {@Parameter(name = "sequence",value="seq_name")})
@GeneratedValue(generator = "idGenerator")
注意 : 該策略要求設(shè)定序列名,否則 hibernate 將無法找到,這將引致拋出異常 :
org.hibernate.exception.SQLGrammarException: could not get next sequence value
③ native
需底層數(shù)據(jù)庫的支持,對(duì)于 MySQL,SQL Server 采用 identity 的生成策略,對(duì)于 Oracle,則采用 sequence 策略。
注解示例 :
@Id
@GenericGenerator(name = "idGenerator", strategy = "native")
@GeneratedValue(generator = "idGenerator")
④ increment [ 自然遞增 ]
與 identity 策略不同的是,該策略不依賴于底層數(shù)據(jù)庫,而依賴于 hibernate 本身,用于為 long 或 short 或 int 類型生成唯一標(biāo)識(shí)。
主鍵計(jì)數(shù)器是由 hibernate 的一個(gè)實(shí)例來維護(hù),每次自增量為 1,但在集群下不能使用該策略,
否則將引起主鍵沖突的情況,該策略適用于所有關(guān)系型數(shù)據(jù)庫使用。
注解示例 :
@Id
@GenericGenerator(name = "idGenerator", strategy = "increment")
@GeneratedValue(generator = "idGenerator")
⑤ uuid [ 32位16進(jìn)制數(shù)的字符串 ]
采用128位UUID算法生成主鍵,能夠保證網(wǎng)絡(luò)環(huán)境下的主鍵唯一性,也就能夠保證在不同數(shù)據(jù)庫及不同服務(wù)器下主鍵的唯一性。
uuid 最終被編碼成一個(gè)32位16進(jìn)制數(shù)的字符串,
占用的存儲(chǔ)空間較大。用于為 String 類型生成唯一標(biāo)識(shí),適用于所有關(guān)系型數(shù)據(jù)庫。
注解示例 :
@Id
@GenericGenerator(name = "idGenerator", strategy = "uuid")
@GeneratedValue(generator = "idGenerator")
⑤ assigned [ 手工分配主鍵ID值 ]
該策略要求程序員必須自己維護(hù)和管理主鍵,當(dāng)有數(shù)據(jù)需要存儲(chǔ)時(shí),程序員必須自己為該數(shù)據(jù)分配指定一個(gè)主鍵ID值,
如果該數(shù)據(jù)沒有被分配主鍵ID值或分配的值存在重復(fù),則該數(shù)據(jù)都將無法被持久化且會(huì)引起異常的拋出。
注解示例 :
@Id
@GenericGenerator(name = "idGenerator", strategy = "assigned")
@GeneratedValue(generator = "idGenerator")
[ 隨筆均原創(chuàng),轉(zhuǎn)載請(qǐng)注明出處:http://www.aygfsteel.com/fancydeepin ]
可能導(dǎo)致異常如下
java.lang.RuntimeException: Unable to start service serviceName with null: java.lang.NullPointerException
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3221)
at android.app.ActivityThread.access$2100(ActivityThread.java:156)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1461)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5872)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1069)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:885)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.ag.rhg.download.DownloadPassService.onStart(Unknown Source)
at android.app.Service.onStartCommand(Service.java:450)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3187)
... 10 more
解決辦法:在Service onStart方法中做判斷
if (null != intent) {
。。。。。。。
} 在android系統(tǒng)中,安裝和卸載都會(huì)發(fā)送廣播,當(dāng)應(yīng)用安裝完成后系統(tǒng)會(huì)發(fā)android.intent.action.PACKAGE_ADDED廣播。可以通過intent.getDataString()獲得所安裝的包名。當(dāng)卸載程序時(shí)系統(tǒng)發(fā)android.intent.action.PACKAGE_REMOVED廣播。同樣intent.getDataString()獲得所卸載的包名。
第一、 新建監(jiān)聽類:BootReceiver繼承BroadcastReceiver































第二、 修改AndroidManifest.xml配置文件
<?xml version="1.0" encoding="UTF-8"?>
<manifest xmlns:android=" package="org.me.watchinstall">
<application>
<receiver android:name=".BootReceiver"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.PACKAGE_ADDED" />
<action android:name="android.intent.action.PACKAGE_REMOVED" />
<data android:scheme="package" />
<!--[color=red] 注意!! 這句必須要加,否則接收不到BroadCast [/color] -->
</intent-filter>
</receiver>
<activity android:name=".WatchInstall" android:label="WatchInstall">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RESTART_PACKAGES"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
</manifest>
1.new->Java Card Project
2.new->Java Card Applet Class->AID Settings

編寫卡內(nèi)程序
public class HelloApplet extends Applet {
public static void install(byte[] bArray, short bOffset, byte bLength) {
// GP-compliant JavaCard applet registration
new HelloApplet().register(bArray, (short) (bOffset + 1),
bArray[bOffset]);
}
public void process(APDU apdu) {
// Good practice: Return 9000 on SELECT
if (selectingApplet()) {
return;
}
byte[] buf = apdu.getBuffer();
short offset = ISO7816.OFFSET_CDATA;
switch (buf[ISO7816.OFFSET_INS]) {
case (byte) 0xE2:
buf[offset++] = 0x01;
buf[offset++] = 0x02;
buf[offset++] = 0x03;
buf[offset++] = 0x04;
buf[offset++] = 0x05;
buf[offset++] = 0x06;
apdu.setOutgoingAndSend(ISO7816.OFFSET_CDATA, (short)(offset-ISO7816.OFFSET_CDATA));
break;
case (byte) 0xE3:
buf[offset++] = 0x11;
buf[offset++] = 0x12;
buf[offset++] = 0x13;
buf[offset++] = 0x14;
buf[offset++] = 0x15;
buf[offset++] = 0x16;
apdu.setOutgoingAndSend(ISO7816.OFFSET_CDATA,(short) (offset-ISO7816.OFFSET_CDATA));
break;
default:
ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
}
}
}
3.右鍵項(xiàng)目->Run Configurations...->Java Card Application右鍵選擇new->選擇新建的Applet->package Upload->aid
4.新建卡外項(xiàng)目java project
編寫卡內(nèi)程序如下:
public class TestHelloWorld {
protected static RFCSMXIO smxio = null;
@Before
public void setUp() throws Exception {
smxio = SMXIOFactory.createJDKSMXIO();
}
@Test
public void test() {
try {
byte[] aid = ByteUtil.hexToByteArray("5200413120");
RFCIOResult result = smxio.selectApplet(aid);
int offset = 0;
byte[] apdu = new byte[5];
apdu[offset] = (byte)0x80;
apdu[offset+1] = (byte)0xE2;
apdu[offset+2] = 0;
apdu[offset+3] = 0;
apdu[offset+4] = 0;
result = smxio.exchange(apdu);
System.out.println("result: "+ByteUtil.byteArrayToHex(result.getResult()));
boolean res = RFCSMXIOHelper.processCardIOResult(result);
byte[] b = result.getResult();
if(res){
System.out.println(ByteUtil.byteArrayToHex(b));
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
6.安裝卡內(nèi)程序jcop debug->upload package->install applet
7.運(yùn)行卡外程序 摘要: Hibernate 參數(shù)設(shè)置一覽表 SQL方言 1、Hibernate JDBC屬性 屬性名 用途 hibernate.connection.driver_class jdbc驅(qū)動(dòng)類 hibernate.connection.url jdbc URL hibernate.connection.username 數(shù)據(jù)庫用戶 ... 閱讀全文 Multiple markers at this line
原因1,這中情況有時(shí)候是jar包中缺少需要的類,沒把需要的類打進(jìn)去
原因2,缺少default.properties文件
從其他工程拷貝一個(gè)過來
原因3,沒有jar包,沒有資源文件
工程右鍵 -> Properties ->android ->選擇一個(gè)android的版本,(如果已經(jīng)選擇好了,還是有問題,就先選擇另一個(gè),之后再換回來)
1.缺少包c(diǎn)ommons-collections-3.1.jar
java.lang.NoClassDefFoundError: org/apache/commons/collections/map/LRUMap
at org.hibernate.util.SimpleMRUCache.init(SimpleMRUCache.java:71)
at org.hibernate.util.SimpleMRUCache.<init>(SimpleMRUCache.java:55)
at org.hibernate.engine.query.QueryPlanCache.<init>(QueryPlanCache.java:76)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:239)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1872)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:906)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:57)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47)
at com.rfcyber.rfcepayment.util.jpa.JPAHelper.init(Unknown Source)
at test.TestDataPreparation.setUp(TestDataPreparation.java:52)
at junit.framework.TestCase.runBare(TestCase.java:128)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:120)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.collections.map.LRUMap
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 22 more
2.缺jta.jar
java.lang.NoClassDefFoundError: javax/transaction/SystemException
at org.hibernate.ejb.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:112)
at org.hibernate.ejb.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:107)
at com.rfcyber.rfcepayment.util.jpa.JPAHelper.getEntityManager(Unknown Source)
at com.rfcyber.rfcepayment.util.jpa.JPADAO.findByJPQL(Unknown Source)
at com.richhouse.personal.service.DPZYTService.searchNextAvaiable(Unknown Source)
at com.richhouse.personal.util.ZYTDPHandler.searchNextAvaiable(Unknown Source)
at com.richhouse.personal.util.ZYTDataPreparation.prepareStoreData(Unknown Source)
at test.TestDataPreparation.testOracleSearchNext(TestDataPreparation.java:91)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at junit.framework.TestCase.runTest(TestCase.java:164)
at junit.framework.TestCase.runBare(TestCase.java:130)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:120)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.ClassNotFoundException: javax.transaction.SystemException
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 24 more
List<ApplicationInfo> installedPackageList = new ArrayList<ApplicationInfo>();
List<ApplicationInfo> list = context.getPackageManager().getInstalledApplications(0);
for (int i = 0; i < list.size(); i++) {
installedPackageList.add(list.get(i));
}
return installedPackageList;
}
| |||||||||
日 | 一 | 二 | 三 | 四 | 五 | 六 | |||
---|---|---|---|---|---|---|---|---|---|
25 | 26 | 27 | 28 | 29 | 30 | 31 | |||
1 | 2 | 3 | 4 | 5 | 6 | 7 | |||
8 | 9 | 10 | 11 | 12 | 13 | 14 | |||
15 | 16 | 17 | 18 | 19 | 20 | 21 | |||
22 | 23 | 24 | 25 | 26 | 27 | 28 | |||
29 | 30 | 1 | 2 | 3 | 4 | 5 |
常用鏈接
留言簿(2)
隨筆分類
- Android(49)
- Androidpn(2)
- hibernate(1)
- Https(1)
- JavaCard(3)
- jQuery(6)
- netty
- NFC(1)
- react框架(1)
- spring(2)
- SpringBoot(1)
- Tomcat+Eclipse(18)
- WebService(2)
- 一些心得(1)
隨筆檔案
- 2020年4月 (4)
- 2015年7月 (5)
- 2015年6月 (6)
- 2015年5月 (4)
- 2015年4月 (3)
- 2015年3月 (1)
- 2015年2月 (1)
- 2015年1月 (4)
- 2014年12月 (1)
- 2014年11月 (2)
- 2014年10月 (2)
- 2014年9月 (2)
- 2014年5月 (5)
- 2014年3月 (3)
- 2014年2月 (2)
- 2014年1月 (8)
- 2013年12月 (2)
- 2013年7月 (2)
- 2013年6月 (4)
- 2013年5月 (16)
- 2012年7月 (1)
- 2012年3月 (2)
- 2011年7月 (6)
文章分類
文章檔案
相冊(cè)
收藏夾
Java
搜索
最新隨筆
最新評(píng)論

- 1.?re: Android JSON的簡單例子
- 評(píng)論內(nèi)容較長,點(diǎn)擊標(biāo)題查看
- --JSON.COM
- 2.?re: androidpn(本文服務(wù)器為tomcat)
- 評(píng)論內(nèi)容較長,點(diǎn)擊標(biāo)題查看
- --Deepak Singh