-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdaocrawler.java
More file actions
88 lines (76 loc) · 2.79 KB
/
daocrawler.java
File metadata and controls
88 lines (76 loc) · 2.79 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
public class daocrawler {
private Connection establishConnection;
private PreparedStatement executestatement;
private ResultSet rset = null;
public int i=0;
daocrawler(){
try {
Class.forName("oracle.jdbc.OracleDriver");
establishConnection = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","system");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void insertProfessorDetails(String Country,String State,String SchoolName,String cityLocatedIn,String OriginatedProfessorName,String departmentName)
{
StringBuffer bufferString = new StringBuffer();
try {
bufferString.append("INSERT INTO professor(PROF_ID,professorname,department,universityname,citylocation,state,country) VALUES (seq_person.nextval,?,?,?,?,?,?)");
executestatement = establishConnection.prepareStatement(bufferString.toString());
executestatement.setString(1,OriginatedProfessorName);
executestatement.setString(2,departmentName);
executestatement.setString(3,SchoolName);
executestatement.setString(4,cityLocatedIn);
executestatement.setString(5,State);
executestatement.setString(6,Country);
establishConnection.setAutoCommit(false);
rset = executestatement.executeQuery();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally{
try {
establishConnection.commit();
} catch (SQLException e) {
System.out.println(" CRITICAL EXCEPTION THROWED AT COMMITING THE STUFF");
e.printStackTrace();
}
}
}
public void insertProfessorComments(String commentslist, Professor profdetails)
{
StringBuffer bufferString = new StringBuffer();
try {
bufferString.append("INSERT INTO PROFESSOR_COMMENTS(professorname,department,universityname,COMMENTS) VALUES (?,?,?,?)");
executestatement = establishConnection.prepareStatement(bufferString.toString());
executestatement.setString(1,profdetails.getOriginatedProfessorName());
executestatement.setString(2,profdetails.getDepartmentName());
executestatement.setString(3,profdetails.getSchoolName());
executestatement.setString(4,commentslist);
establishConnection.setAutoCommit(false);
rset = executestatement.executeQuery();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally{
try {
establishConnection.commit();
} catch (SQLException e) {
System.out.println(" CRITICAL EXCEPTION THROWED AT COMMITING THE STUFF");
e.printStackTrace();
}
}
}
}