總網頁瀏覽量

2017年6月29日 星期四

FileZilla 搜尋

一般要做搜尋, 按下 F3 遠端檔案搜尋

搜尋條件: 
比對以下任何項目 <<
符合以下任何項目
不符合以下任何項目

搜尋條件: 
檔案名稱     
檔案大小     
檔案路徑     
日期            

包含
等於
起始於                  
終止於 
比對常規表示寶
不包含




其實看了這麼多, 眼殘忘了看後面還有個 [+] ,
用這個家就可以增加條件做篩選,
不用手動在那裏挑了....



2017年3月2日 星期四

[Java] 顯示時間 毫秒

顯示目前系統時間, 只是因為找到的中文分享多半是到秒就結束了,
所以另外寫一個讓秒後4碼也顯示出來的方法.
另外寫的功能就是想要 x 分鐘前後也顯示出來,
所以函式的輸入就是 x .

public String getTime(int min){
        SimpleDateFormat t = new SimpleDateFormat("yyyyMMddhhmmssSSSS");
        Date d = new Date();       
        String sd = t.format(new Date(d.getTime()+(long)min *60*1000));   
   
        System.out.println("Now: "+t.format(d.getTime()));
        System.out.println("Chg: "+sd);
        return sd;       
    }

Output:
Now: 201703020604270563
Chg: 201703020603270563




2017年2月22日 星期三

[Java] Eclipse 編譯不執行

我應該是全世界第2^100個知道的吧

 Eclipse 按下儲存鍵的同時就會做編譯了...

為啥?

Project >Build Automatically 被打勾了













所以儲存的同時就會做編譯, class檔就出現了.

要關掉可以, 靶溝溝按掉



 按 Project > Build Project 就好了


2017年2月2日 星期四

[JAVA] Calendar 類別

Oracle 文章寫這樣

Returns the value of the given calendar field. In lenient mode, all calendar fields are normalized. In non-lenient mode, all calendar fields are validated and this method throws an exception if any calendar fields have out-of-range values. The normalization and validation are handled by the complete() method, which process is calendar system dependent.

完全看不懂

所以自己測


import java.util.Calendar;

public class dataaaaa{
    public static void main(String args[]){
        Calendar ca = Calendar.getInstance();
        for(int i = 0 ; i <= 10 ; i++)
            System.out.println(i+": "+ca.get(i));
    }
}


output :

0: 1
1: 2017
2: 1
3: 5
4: 1
5: 3
6: 34
7: 6
8: 1
9: 0
10: 11


看不懂 ? 正常

ID  Value  Description
--  -----  -----------
 0      1  Era (BC/AD for Gregorian).
 1   2017  Year.年
 2      1  Month (zero-based).月(以0開始算)
 3      5  Week-of-year.(今年第幾個禮拜)
 4      1  Week-of-month.(這個月第個禮拜)
 5      3  Date/day-of-month.(這個月第幾天)
 6     34  Day-of-year.(今年第幾天)
 7      6  Day-of-week.(這禮拜第幾天)
 8      1  Day-of-week-in-month.(今天是這個月的第幾個禮拜)
 9      0  AM/PM selector.(上午0/下午1)
10     11  Hour.(幾點 時部分)
 
 
[1] https://docs.oracle.com/javase/7/docs/api/java/util/Calendar.html#get(int) 
[2] http://stackoverflow.com/questions/6605471/what-does-object-calendar-do 

2017年1月24日 星期二

[JAVA] 與phpmyadmin建立連線參數

import java.sql.Connection;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.DriverManager;
import java.sql.ResultSetMetaData;

public class ConnectiontoDB{
    static final String DRIVER = "com.mysql.jdbc.Driver";
    static final String DATABASE_URL =
             "jdbc:mysql://[主機位置]:3306/[資料庫名稱]?autoReconnect=true&useSSL=false";
   
    public static void main(String args[]){
        Connection connection = null;       
        try{
    Class.forName(DRIVER);
        }catch(ClassNotFoundException e){
    System.out.println("DRIVER ERROR: "+e);}
       
        try{           
            connection = DriverManager.getConnection(DATABASE_URL,"[帳號]","[密碼]");
        }catch(Exception e){
    System.out.println("forName: "+e);
  }
    }
}

加上藍色這段主要是因為不佳的時候會出現錯誤訊息
Tue Jan 24 23:17:26 CST 2017 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.

雖然是版本問題, 但是如果改成useSSL=false就像是跳過SSL連線依樣, 其實蠻糟糕的,
所以使用的時候還是記得用useSSL= true 安全一點.

至於現在用兩個try-catch主要是讓我更知道錯誤的訊息在哪出現,
雖然蠻多餘的  ㄎㄎ. 不過這樣就知道是DRIVER錯誤還是連線錯,

雖然這次的錯誤訊息是版本問題的錯誤....