說明:
[Android]Cordova使用Sqlite資料庫
什麼是SQLite?
SQLite是一個軟體資料庫,不需要架設在伺服端的自主資料庫,用來存放數據資料。
行動裝置上對於資料的存取需求相對比少,不太需要大量的記憶體及cpu,對於行動裝置是個很好的選擇。
當我們利用Cordova/PhoneGap開發行動裝置時,可以增加plugin來支援Sqlite的使用,再結合html 5、CSS、Javascript就可以存取資料並顯示其結果。
Cordova plugin SQLite
https://github.com/brodysoft/Cordova-SQLitePlugin
A Cordova/PhoneGap plugin to open and use sqlite databases on Android/iOS/WP(8) with HTML5 Web SQL API
Native interface to sqlite in a Cordova/PhoneGap plugin for Android/iOS/WP(8), with HTML5 Web SQL API
License for Android & WP(8) versions: MIT or Apache 2.0
License for iOS version: MIT only
舊的專案網址
[Java]日期常用工具函數整理
字串轉換成Timestamp格式
package yku;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
public class DateUtils {
private static SimpleDateFormat datetimeformat = new SimpleDateFormat(
"yyyy/MM/dd HH:mm:ss");
private static SimpleDateFormat dateformat = new SimpleDateFormat(
"yyyy/MM/dd");
public static Timestamp convertDate(String str) {
if (str == null || str.length() == 0)
return null;
try {
return new Timestamp(dateformat.parse(str).getTime());
} catch (Exception e) {
//e.printStackTrace();
}
return null;
}
public static Timestamp convertDateTime(String str) {
if (str == null || str.length() == 0)
return null;
try {
return new Timestamp(datetimeformat.parse(str).getTime());
} catch (Exception e) {
//e.printStackTrace();
}
return null;
}
public static void main(String args[]) {
System.out.println("1."+DateUtils.convertDate("2014/01/01").toString());
System.out.println("2."+(DateUtils.convertDate("2014/0101")==null?"錯誤日期格式":"正確日期格式"));
System.out.println("這裡是分割線---------------------------------------------------");
System.out.println("3."+DateUtils.convertDateTime("2014/01/01 12:33:21").toString());
System.out.println("4."+(DateUtils.convertDate("2014/0101 123321")==null?"錯誤日期時間格式":"正確日期時間格式"));
}
}
Ans:
1.2014-01-01 00:00:00.0 2.錯誤日期格式 這裡是分割線--------------------------------------------------- 3.2014-01-01 12:33:21.0 4.錯誤日期時間格式
[JAVA]JDBC Driver整理
jTDS Driver
Microsoft SQL Server (6.5, 7, 2000, 2005, 2008 and 2012) and Sybase Adaptive Server Enterprise (10, 11, 12 and 15)
Drive Class: net.sourceforge.jtds.jdbc.Driver
Drive Location: http://jtds.sourceforge.net/
JDBC Url Format: jdbc:jtds:sqlserver://<host>:<port>/<database_name>
MsSQL Server預設port為1433
Examples:
jdbc:jtds:sqlserver://blog.yslifes.com:1433/test
jdbc:jtds:sqlserver://127.0.0.1:1433/test