-
Notifications
You must be signed in to change notification settings - Fork 0
/
MySql.java
51 lines (43 loc) · 1.37 KB
/
MySql.java
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import java.sql.*;
import java.util.*;
import universal.database.DatabaseMySql;
class MySql{
public static void main(String[] args){
DatabaseMySql sql = new DatabaseMySql("localhost:3306","University","root","sanheen");
String query = "";
ResultSet rs1 = sql.select().from("students").srun();
query = sql.getQuery();
System.out.println("Query : "+query);
ResultSet rs2 = sql.select("id").from("students").srun();
query = sql.getQuery();
System.out.println("Query : "+query);
ResultSet rs3 = sql.select("name").from("students").srun();
query = sql.getQuery();
System.out.println("Query : "+query);
ResultSet rs4 = sql.select("age").from("students").srun();
query = sql.getQuery();
System.out.println("Query : "+query);
ResultSet rs5 = sql.select("id","age").from("students").srun();
query = sql.getQuery();
System.out.println("Query : "+query);
ResultSet rs6 = sql.select("id","name").from("students").srun();
query = sql.getQuery();
System.out.println("Query : "+query);
ResultSet rs = rs6;
try{
while(rs.next()){
int id = rs.getInt(1);
String name = rs.getString(2);
//int age = rs1.getInt("age");
System.out.print(id);
System.out.print(" | ");
System.out.print(name);
//System.out.print(" | ");
//System.out.print(age);
System.out.println();
}
}catch(SQLException e){
System.out.println(e);
}
}
}