Skip to content

Commit cf320c6

Browse files
committed
error more
1 parent 91cc67e commit cf320c6

File tree

8 files changed

+68
-111
lines changed

8 files changed

+68
-111
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<table>
3-
<name DataType="varchar">yahia</name>
43
<age DataType="int">-15</age>
54
</table>
Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
22
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
3-
<xs:complexType name="nameType">
4-
<xs:simpleContent>
5-
<xs:extension base="xs:string">
6-
<xs:attribute name="DataType" type="xs:string"/>
7-
</xs:extension>
8-
</xs:simpleContent>
9-
</xs:complexType>
103
<xs:complexType name="ageType">
114
<xs:simpleContent>
125
<xs:extension base="xs:string">
@@ -16,7 +9,6 @@
169
</xs:complexType>
1710
<xs:complexType name="tableType">
1811
<xs:sequence>
19-
<xs:element name="name" type="nameType"/>
2012
<xs:element name="age" type="ageType"/>
2113
</xs:sequence>
2214
</xs:complexType>

dist/JDBC-API.jar

4 Bytes
Binary file not shown.

dist/Log.txt

Lines changed: 27 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,27 @@
1-
[ FINER ] 12\07\2019 , 15:20 : Connection Initiated
2-
[ FINER ] 12\07\2019 , 15:20 : Statement Created
3-
[ SEVERE ] 12\07\2019 , 15:20 : Use Query failed!
4-
[ FINE ] 12\07\2019 , 15:20 : Connection Closed
5-
[ FINE ] 12\07\2019 , 15:20 : Statement Closed
6-
[ FINER ] 12\07\2019 , 15:20 : Connection Initiated
7-
[ FINER ] 12\07\2019 , 15:20 : Statement Created
8-
[ FINE ] 12\07\2019 , 15:20 : Connection Closed
9-
[ FINE ] 12\07\2019 , 15:20 : Statement Closed
10-
[ FINER ] 12\07\2019 , 15:20 : Connection Initiated
11-
[ FINER ] 12\07\2019 , 15:20 : Statement Created
12-
[ FINE ] 12\07\2019 , 15:20 : Connection Closed
13-
[ FINE ] 12\07\2019 , 15:20 : Statement Closed
14-
[ FINER ] 12\07\2019 , 15:20 : Connection Initiated
15-
[ FINER ] 12\07\2019 , 15:20 : Statement Created
16-
[ FINE ] 12\07\2019 , 15:20 : Connection Closed
17-
[ FINE ] 12\07\2019 , 15:20 : Statement Closed
18-
[ FINER ] 12\07\2019 , 15:20 : Connection Initiated
19-
[ FINER ] 12\07\2019 , 15:20 : Statement Created
20-
[ FINE ] 12\07\2019 , 15:20 : Select Query executed
21-
[ FINE ] 12\07\2019 , 15:20 : Connection Closed
22-
[ FINE ] 12\07\2019 , 15:20 : Statement Closed
23-
[ FINER ] 12\07\2019 , 15:20 : Connection Initiated
24-
[ FINER ] 12\07\2019 , 15:20 : Statement Created
25-
[ FINE ] 12\07\2019 , 15:21 : Select Query executed
26-
[ FINE ] 12\07\2019 , 15:21 : Connection Closed
27-
[ FINE ] 12\07\2019 , 15:21 : Statement Closed
28-
[ FINER ] 12\07\2019 , 15:21 : Connection Initiated
29-
[ FINER ] 12\07\2019 , 15:21 : Statement Created
30-
[ FINE ] 12\07\2019 , 15:21 : Connection Closed
31-
[ FINE ] 12\07\2019 , 15:21 : Statement Closed
32-
[ FINER ] 12\07\2019 , 15:21 : Connection Initiated
33-
[ FINER ] 12\07\2019 , 15:21 : Statement Created
34-
[ FINE ] 12\07\2019 , 15:21 : Select Query executed
35-
[ FINE ] 12\07\2019 , 15:21 : Connection Closed
36-
[ FINE ] 12\07\2019 , 15:21 : Statement Closed
37-
[ FINER ] 12\07\2019 , 15:21 : Connection Initiated
38-
[ FINER ] 12\07\2019 , 15:21 : Statement Created
39-
[ FINE ] 12\07\2019 , 15:21 : Connection Closed
40-
[ FINE ] 12\07\2019 , 15:21 : Statement Closed
41-
[ FINER ] 12\07\2019 , 15:21 : Connection Initiated
42-
[ FINER ] 12\07\2019 , 15:21 : Statement Created
43-
[ SEVERE ] 12\07\2019 , 15:21 : Select Query failed
44-
[ FINE ] 12\07\2019 , 15:21 : Connection Closed
45-
[ FINE ] 12\07\2019 , 15:21 : Statement Closed
46-
[ FINER ] 12\07\2019 , 15:21 : Connection Initiated
47-
[ FINER ] 12\07\2019 , 15:21 : Statement Created
48-
[ FINE ] 12\07\2019 , 15:21 : Select Query executed
49-
[ FINE ] 12\07\2019 , 15:21 : Connection Closed
50-
[ FINE ] 12\07\2019 , 15:21 : Statement Closed
51-
[ FINER ] 12\07\2019 , 15:21 : Connection Initiated
52-
[ FINER ] 12\07\2019 , 15:21 : Statement Created
53-
[ SEVERE ] 12\07\2019 , 15:21 : Select Query failed
54-
[ FINE ] 12\07\2019 , 15:21 : Connection Closed
55-
[ FINE ] 12\07\2019 , 15:21 : Statement Closed
56-
[ FINER ] 12\07\2019 , 15:21 : Connection Initiated
57-
[ FINER ] 12\07\2019 , 15:21 : Statement Created
58-
[ FINER ] 12\07\2019 , 15:26 : Connection Initiated
59-
[ FINER ] 12\07\2019 , 15:26 : Statement Created
60-
[ FINE ] 12\07\2019 , 15:26 : Use Query executed
61-
[ FINE ] 12\07\2019 , 15:26 : Connection Closed
62-
[ FINE ] 12\07\2019 , 15:26 : Statement Closed
63-
[ FINER ] 12\07\2019 , 15:26 : Connection Initiated
64-
[ FINER ] 12\07\2019 , 15:26 : Statement Created
65-
[ FINE ] 12\07\2019 , 15:26 : Select Query executed
66-
[ FINE ] 12\07\2019 , 15:26 : Connection Closed
67-
[ FINE ] 12\07\2019 , 15:26 : Statement Closed
68-
[ FINER ] 12\07\2019 , 15:26 : Connection Initiated
69-
[ FINER ] 12\07\2019 , 15:26 : Statement Created
70-
[ FINE ] 12\07\2019 , 15:26 : Update Query executed
71-
[ FINE ] 12\07\2019 , 15:26 : Connection Closed
72-
[ FINE ] 12\07\2019 , 15:26 : Statement Closed
73-
[ FINER ] 12\07\2019 , 15:26 : Connection Initiated
74-
[ FINER ] 12\07\2019 , 15:26 : Statement Created
75-
[ FINE ] 12\07\2019 , 15:27 : Select Query executed
76-
[ FINE ] 12\07\2019 , 15:27 : Connection Closed
77-
[ FINE ] 12\07\2019 , 15:27 : Statement Closed
78-
[ FINER ] 12\07\2019 , 15:27 : Connection Initiated
79-
[ FINER ] 12\07\2019 , 15:27 : Statement Created
80-
[ SEVERE ] 12\07\2019 , 15:27 : Select Query failed
81-
[ FINE ] 12\07\2019 , 15:27 : Connection Closed
82-
[ FINE ] 12\07\2019 , 15:27 : Statement Closed
83-
[ FINER ] 12\07\2019 , 15:27 : Connection Initiated
84-
[ FINER ] 12\07\2019 , 15:27 : Statement Created
85-
[ SEVERE ] 12\07\2019 , 15:27 : Select Query failed
86-
[ FINE ] 12\07\2019 , 15:27 : Connection Closed
87-
[ FINE ] 12\07\2019 , 15:27 : Statement Closed
88-
[ FINER ] 12\07\2019 , 15:27 : Connection Initiated
89-
[ FINER ] 12\07\2019 , 15:27 : Statement Created
90-
[ SEVERE ] 12\07\2019 , 15:27 : Select Query failed
91-
[ FINE ] 12\07\2019 , 15:27 : Connection Closed
92-
[ FINE ] 12\07\2019 , 15:27 : Statement Closed
93-
[ FINER ] 12\07\2019 , 15:27 : Connection Initiated
94-
[ FINER ] 12\07\2019 , 15:27 : Statement Created
1+
[ FINER ] 12\07\2019 , 15:59 : Connection Initiated
2+
[ FINER ] 12\07\2019 , 15:59 : Statement Created
3+
[ FINE ] 12\07\2019 , 15:59 : Connection Closed
4+
[ FINE ] 12\07\2019 , 15:59 : Statement Closed
5+
[ FINER ] 12\07\2019 , 15:59 : Connection Initiated
6+
[ FINER ] 12\07\2019 , 15:59 : Statement Created
7+
[ FINE ] 12\07\2019 , 15:59 : Connection Closed
8+
[ FINE ] 12\07\2019 , 15:59 : Statement Closed
9+
[ FINER ] 12\07\2019 , 15:59 : Connection Initiated
10+
[ FINER ] 12\07\2019 , 15:59 : Statement Created
11+
[ FINE ] 12\07\2019 , 15:59 : Update Query executed
12+
[ FINE ] 12\07\2019 , 15:59 : Connection Closed
13+
[ FINE ] 12\07\2019 , 15:59 : Statement Closed
14+
[ FINER ] 12\07\2019 , 15:59 : Connection Initiated
15+
[ FINER ] 12\07\2019 , 15:59 : Statement Created
16+
[ FINE ] 12\07\2019 , 16:00 : Select Query executed
17+
[ FINE ] 12\07\2019 , 16:00 : Connection Closed
18+
[ FINE ] 12\07\2019 , 16:00 : Statement Closed
19+
[ FINER ] 12\07\2019 , 16:00 : Connection Initiated
20+
[ FINER ] 12\07\2019 , 16:00 : Statement Created
21+
[ FINE ] 12\07\2019 , 16:00 : Select Query executed
22+
[ FINE ] 12\07\2019 , 16:00 : Connection Closed
23+
[ FINE ] 12\07\2019 , 16:00 : Statement Closed
24+
[ FINER ] 12\07\2019 , 16:00 : Connection Initiated
25+
[ FINER ] 12\07\2019 , 16:00 : Statement Created
26+
[ FINER ] 12\07\2019 , 16:13 : Connection Initiated
27+
[ FINER ] 12\07\2019 , 16:13 : Statement Created

src/eg/edu/alexu/csd/oop/cs71/db/FileManagement.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import java.util.Arrays;
1818
import java.util.HashMap;
1919

20-
public class FileManagement implements FileManagementInterface{
20+
public class FileManagement extends FileManagementInterface{
2121
public void writeInFile(String tableName, HashMap<String, String> tableColumns, ArrayList<HashMap<String, Object>> tableData, String currentDatabase,ArrayList <String> cNames, ArrayList<String> cTypes){
2222
String[] columnContents =new String[tableColumns.size()];
2323
Arrays.fill(columnContents, "");

src/eg/edu/alexu/csd/oop/cs71/db/FileManagementInterface.java

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,41 @@
88
import java.util.ArrayList;
99
import java.util.HashMap;
1010

11-
public interface FileManagementInterface {
12-
void writeInFile(String tableName, HashMap<String, String> tableColumns, ArrayList<HashMap<String, Object>> tableData, String currentDatabase,ArrayList <String> cNames, ArrayList<String> cTypes);
13-
void readFile(String tableName, HashMap<String, String> tableColumns, ArrayList<HashMap<String, Object>> tableData, String currentDatabase, ArrayList<String> cNames, ArrayList<String> cTypes) throws IOException, ParserConfigurationException, SAXException;
14-
String getTableName(String query);
11+
public abstract class FileManagementInterface {
12+
abstract void writeInFile(String tableName, HashMap<String, String> tableColumns, ArrayList<HashMap<String, Object>> tableData, String currentDatabase,ArrayList <String> cNames, ArrayList<String> cTypes);
13+
abstract void readFile(String tableName, HashMap<String, String> tableColumns, ArrayList<HashMap<String, Object>> tableData, String currentDatabase, ArrayList<String> cNames, ArrayList<String> cTypes) throws IOException, ParserConfigurationException, SAXException;
14+
String getTableName(String query){
15+
String tableName="";
16+
String[] parts=query.split(" ");
17+
parts[0]=parts[0].toLowerCase();
18+
switch (parts[0])
19+
{
20+
case "select":{
21+
int index=0;
22+
for (String x:parts) {
23+
x=x.toLowerCase();
24+
if(x.equals("from")){
25+
index++;
26+
break;
27+
}
28+
index++;
29+
}
30+
tableName=parts[index];
31+
}
32+
break;
33+
case "insert":
34+
case "alter":
35+
case "delete":{
36+
tableName=parts[2];
37+
parts=tableName.split("\\(" );
38+
tableName=parts[0];
39+
}
40+
break;
41+
case "update":{
42+
tableName=parts[1];
43+
}
44+
break;
45+
}
46+
return tableName;
47+
}
1548
}

src/eg/edu/alexu/csd/oop/cs71/db/SQLParser.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,12 +319,12 @@ public int alter(String query, ArrayList<String> cNames, ArrayList<String> cType
319319
}
320320

321321
private void operationParser(String query, ArrayList<String> colNames, ArrayList<String> colTypes, ArrayList<HashMap<String, Object>> table) {
322-
query = query.replaceAll("\\s+|\\(+|\\)|\\,|(?i)(and\\s+(?='|\\d))|\\;", " ");
322+
query = query.replaceAll("\\s+|\\(+|\\)|\\,|(?i)(and\\s+(?='|-?\\d))|\\;", " ");
323323
query = query.replaceAll("\\s*\\<\\>\\s*", " != ");
324324
query = query.replaceAll("\\s+(?=\\=)", "");
325-
Pattern P1 = Pattern.compile("\\A[\\s]*(\\w+)[\\s]*(<|>|>\\s*=|<\\s*=|!\\s*=|=)[\\s]*([']?\\w+[']?)[\\s]*\\z");
325+
Pattern P1 = Pattern.compile("\\A[\\s]*(\\w+)[\\s]*(<|>|>\\s*=|<\\s*=|!\\s*=|=)[\\s]*([']?-?\\w+[']?)[\\s]*\\z");
326326
Matcher M1;
327-
Pattern P2 = Pattern.compile("\\A[\\s]*(\\w+)[\\s]*((?i)between|in)([\\s]*([']?\\w+[']?)[\\s]*)+\\z");
327+
Pattern P2 = Pattern.compile("\\A[\\s]*(\\w+)[\\s]*((?i)between|in)([\\s]*([']?-?\\w+[']?)[\\s]*)+\\z");
328328
Matcher M2;
329329
logicOperatorParser(query, colNames, colTypes, table);
330330
query = query.replaceAll("(?i)(not)\\s*", "");

0 commit comments

Comments
 (0)