Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
bcf7f45
branch tutorial
luanxiangming Jun 24, 2017
e94117c
init tutorial
luanxiangming Jun 25, 2017
5a1487a
loops
luanxiangming Jun 25, 2017
bc5738e
IfElseSwitch, Numbers
luanxiangming Jun 25, 2017
16b5110
Character, String
luanxiangming Jun 26, 2017
0a8bd0d
StringBuffer
luanxiangming Jun 26, 2017
0a94b2e
Array
luanxiangming Jun 27, 2017
9d34e53
Date
luanxiangming Jun 27, 2017
217b34f
Calendar
luanxiangming Jun 28, 2017
c4b11ba
Regex
luanxiangming Jun 28, 2017
2fb275d
Method
luanxiangming Jun 28, 2017
f9efa29
IO
luanxiangming Jun 28, 2017
d533590
File
luanxiangming Jun 28, 2017
ec0a105
Scanner
luanxiangming Jun 28, 2017
f5337c1
Exception
luanxiangming Jun 29, 2017
7023f08
Extends
luanxiangming Jun 29, 2017
1f7ba2e
Override, Overload
luanxiangming Jun 29, 2017
e6ec5a2
Abstract
luanxiangming Jun 29, 2017
dbb9725
Encapsulation
luanxiangming Jun 29, 2017
769e08b
Interface
luanxiangming Jun 30, 2017
18ae951
Package
luanxiangming Jun 30, 2017
dd2289c
BitSet, Enumeration, Stack, Vector
luanxiangming Jun 30, 2017
295ee52
Map, Hashtable, Properties
luanxiangming Jun 30, 2017
bd581d4
Collection
luanxiangming Jul 1, 2017
5e71044
Generic<T>
luanxiangming Jul 1, 2017
3ad8de5
Serializable
luanxiangming Jul 2, 2017
2804af0
JavaMail
luanxiangming Jul 4, 2017
3e8a98a
Runnable, Callable, Thread
luanxiangming Jul 5, 2017
8e030b7
Array, String
luanxiangming Jul 6, 2017
5304f91
Date
luanxiangming Jul 6, 2017
ccb1583
Collections
luanxiangming Jul 8, 2017
1f0efff
method
luanxiangming Jul 9, 2017
ccb9406
File
luanxiangming Jul 10, 2017
7876758
network, socket
luanxiangming Jul 11, 2017
a28de1e
thread
luanxiangming Jul 12, 2017
4d20e73
method reference, functional interface, lambda
luanxiangming Jul 13, 2017
174bffe
default method, stream
luanxiangming Jul 13, 2017
c074eed
Optional
luanxiangming Jul 13, 2017
89da3b9
java.time
luanxiangming Jul 14, 2017
571a0a6
Base64
luanxiangming Jul 14, 2017
4f67fb9
mysql
luanxiangming Jul 14, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,26 @@
.idea/**/*
interfacetest.iml
/test-output/
### Java template
# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package file.Files #
#*.jar
*.war
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
35 changes: 1 addition & 34 deletions failCount.properties
Original file line number Diff line number Diff line change
@@ -1,34 +1 @@
#
#Mon Apr 17 18:22:26 CST 2017
uploadWithFileConvert=0
registerVipJr=0
loginVipjr=0
getAfterQuestion=0
reviewPage=1
getClientReservedLessons=1
getClientClasses=0
lessonInfo=1
setReservation=0
newLogin=0
getClientLessonHistory=0
getList=0
getJRHotNewsList=0
lessonQuestions=1
getLevelInfo=0
setAfterQuestionEvaluation=0
homeLogin=0
getClientBasicInfoByEmail=0
activateAccount=0
preparePage=1
reservationInformation=0
getClientClassRecordTimeList=1
beforeTest=2
getJRNewsDetailByNewsID=0
afterTest=0
checkRegisterMail=0
getDCGS=0
lessonVocab=1
classContract=0
data=0
viewMyVideo=0
recommandList=0
中文输入
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.4.4</version>
<version>1.4.7</version>
</dependency>
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
Expand Down
127 changes: 65 additions & 62 deletions src/main/java/com/vipabc/interfacetest/utils/ConnectToDB.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,102 +11,105 @@

public class ConnectToDB {

private Connection conn;
private Connection conn;

public ConnectToDB() {
String driver = "com.mysql.cj.jdbc.Driver";
public ConnectToDB() {
String driver = "com.mysql.cj.jdbc.Driver";

String url = "jdbc:mysql://172.16.233.82:3306/vfs";
String url = "jdbc:mysql://172.16.233.82:3306/vfs";

String user = "vfsdev";
String user = "vfsdev";

String password = "vfs123";
String password = "vfs123";

try {
Class.forName(driver);
conn = DriverManager.getConnection(url, user, password);
if (!conn.isClosed())
System.out.println("Succeeded connecting to the Database!");
} catch (ClassNotFoundException e) {
try {
Class.forName(driver);
conn = DriverManager.getConnection(url, user, password);
if (!conn.isClosed())
System.out.println("Succeeded connecting to the Database!");
} catch (ClassNotFoundException e) {

System.out.println("Sorry,can't find the Driver!");
e.printStackTrace();
System.out.println("Sorry,can't find the Driver!");
e.printStackTrace();

} catch (SQLException e) {
} catch (SQLException e) {

e.printStackTrace();
e.printStackTrace();

} catch (Exception e) {
} catch (Exception e) {

e.printStackTrace();
e.printStackTrace();

}
}
}
}

public List<HashMap<String, String>> query(String table, String key) throws SQLException {
Statement statement = conn.createStatement();
public List<HashMap<String, String>> query(String table, String key) throws SQLException {
Statement statement = conn.createStatement();
ResultSet rs = statement.executeQuery("select * from " + table);
List<HashMap<String, String>> result = new ArrayList<HashMap<String, String>>();

ResultSetMetaData md = rs.getMetaData();
int cc = md.getColumnCount();
while (rs.next()) {
while (rs.next()) {
HashMap<String, String> columnMap = new HashMap<String, String>();
for (int i = 1; i <= cc; i++) {
columnMap.put(md.getColumnName(i), rs.getString(i));
}
result.add(columnMap);
}
rs.close();
conn.close();
return result;
}
}
rs.close();
conn.close();
return result;
}

public List<HashMap<String, String>> query(String sql) throws SQLException {
Statement statement = conn.createStatement();
ResultSet rs = statement.executeQuery(sql);
List<HashMap<String, String>> result = new ArrayList<HashMap<String, String>>();
public List<HashMap<String, String>> query(String sql) throws SQLException {
Statement statement = conn.createStatement();
ResultSet rs = statement.executeQuery(sql);
List<HashMap<String, String>> result = new ArrayList<HashMap<String, String>>();

ResultSetMetaData md = rs.getMetaData();
int cc = md.getColumnCount();
while (rs.next()) {
while (rs.next()) {
HashMap<String, String> columnMap = new HashMap<String, String>();
for (int i = 1; i <= cc; i++) {
columnMap.put(md.getColumnName(i), rs.getString(i));
}
result.add(columnMap);
}
rs.close();
}
rs.close();
// conn.close();
return result;
}

public void insert(String sql) throws SQLException {
Statement statement = conn.createStatement();
statement.executeUpdate(sql);
}
public void update(String sql) throws SQLException {
Statement statement = conn.createStatement();
statement.executeUpdate(sql);
}
public void delete(String sql) throws SQLException {
Statement statement = conn.createStatement();
statement.executeUpdate(sql);
}
public void closeDBcon(){
try {
conn.close();
} catch (SQLException ex) {
Logger.getLogger(Oracle.class.getName()).log(Level.SEVERE, null, ex);
}
}

public static void main(String args[]) throws SQLException {
ConnectToDB cdb = new ConnectToDB();
cdb.query("visit_identitify_code", "code_value");
cdb.query("visit_identitify_code", "status");
}

public void insert(String sql) throws SQLException {
Statement statement = conn.createStatement();
statement.executeUpdate(sql);
}

public void update(String sql) throws SQLException {
Statement statement = conn.createStatement();
statement.executeUpdate(sql);
}

public void delete(String sql) throws SQLException {
Statement statement = conn.createStatement();
statement.executeUpdate(sql);
}

public void closeDBcon() {
try {
conn.close();
} catch (SQLException ex) {
Logger.getLogger(Oracle.class.getName()).log(Level.SEVERE, null, ex);
}
}

public static void main(String args[]) throws SQLException {
ConnectToDB cdb = new ConnectToDB();
cdb.query("visit_identitify_code", "code_value");
cdb.query("visit_identitify_code", "status");
// cdb.insert("INSERT INTO visit_identitify_code"
// + " (`id`, `creater`, `create_time`, `modifier`, `modify_time`, `version`, `code_value`, `follow_id`, `status`, `client_linkman_id`)"
// + "VALUES (3, -1, '2014/5/29 17:00:00', NULL, NULL, 0, '4321', 1, 'visiting', 1);");
}
}
}
96 changes: 96 additions & 0 deletions src/tutorial/Abstracts.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/**
* Created by Oliver on 29/06/2017.
*/
public class Abstracts {
public static void main(String[] args) {
Salary s = new Salary("James Salary", "Shanghai", 7, 20000);
Employee e = new Salary("John Employee", "Tokyo", 9, 30000);

System.out.println("Call mailCheck using Salary reference --");
s.mailCheck();

System.out.println("\nCall mailCheck using Employee reference --");
e.mailCheck();
}

}


class Salary extends Employee {
private double salary;

public Salary(String name, String address, int number, double salary) {
super(name, address, number);
setSalary(salary);
}

public void setSalary(double salary) {
if (salary >= 0) {
this.salary = salary;
}
}

public double getSalary() {
return this.salary;
}

// 任何子类必须重写父类的抽象方法,或者声明自身为抽象类
public double computePay() {
System.out.println("Inside Salary computePay");
return this.salary;
}

public void mailCheck() {
System.out.println("Within mailCheck of Salary class ");
System.out.println("Mailing a check to " + getName()
+ " " + getAddress());
}
}

/* 抽象类总结
1. 抽象类不能被实例化,如果被实例化,就会报错,编译无法通过。只有抽象类的非抽象子类可以创建对象。
2. 抽象类中不一定包含抽象方法,但是有抽象方法的类必定是抽象类。
3. 抽象类中的抽象方法只是声明,不包含方法体,就是不给出方法的具体实现也就是方法的具体功能。
4. 构造方法,类方法(用static修饰的方法)不能声明为抽象方法。
5. 抽象类的子类必须给出抽象类中的抽象方法的具体实现,除非该子类也是抽象类。
*/
abstract class Employee {
private String name;
private String address;
private int number;

public Employee(String name, String address, int number) {
System.out.println("Constructing an Employee");
this.name = name;
this.address = address;
this.number = number;
}

// 抽象方法只能在抽象类
public abstract double computePay();

public void mailCheck() {
System.out.println("Mailing a check to " + this.name
+ " " + this.address);
}

public String toString() {
return name + " " + address + " " + number;
}

public String getName() {
return name;
}

public String getAddress() {
return address;
}

public void setAddress(String newAddress) {
address = newAddress;
}

public int getNumber() {
return number;
}
}
53 changes: 53 additions & 0 deletions src/tutorial/Arrays.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* Created by Oliver on 27/06/2017.
*/
public class Arrays {
public static void Array_for() {
double[] myList = {1.9, 2.9, 3.4, 3.5};
for (int i = 0; i < myList.length; i++) {
System.out.println(myList[i]);
}

double total = 0d;
for (int i = 0; i < myList.length; i++) {
total += myList[i];
}
System.out.println("Total: " + total);

double max = myList[0];
for (int i = 0; i < myList.length; i++) {
max = Math.max(myList[i], max);
}
System.out.println("Max: " + max);
}

public static void Array_foreach() {
double[] myList = {1.9, 2.9, 3.4, 3.5};
for (double item : myList) {
System.out.println(item);
}
}

public static int[] reverse(int[] array) {
int[] result = new int[array.length];
for (int i = 0, j = result.length - 1; i < array.length; i++, j--) {
result[i] = array[j];
}
return result;
}

public static void Array_reverse() {
int[] arr = {1, 2, 3, 4, 5};
int[] reversed = reverse(arr);
for (int i : reversed) {
System.out.println(i);
}
}

public static void main(String[] args) {
Array_for();
Array_foreach();
Array_reverse();
}

}
Loading