-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPosts_Window.java
98 lines (74 loc) · 2.46 KB
/
Posts_Window.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
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
89
90
91
92
93
94
95
96
97
98
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package focus;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.application.Application;
import javafx.collections.ObservableList;
import javafx.scene.Scene;
import javafx.scene.control.TextArea;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
/**
*
* @author rakesh
*/
public class Posts_Window extends Application {
int counter; //Assign counter from Question Window
Connection con=null;
Statement stmt=null;
ResultSet rs=null;
/**
*
* @param counter
*/
public Posts_Window(int counter){
this.counter=counter;
try {
//Initialize DB
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/crawler","root","");
stmt=con.createStatement();
} catch (ClassNotFoundException|SQLException ex) {
Logger.getLogger(Question_Window.class.getName()).log(Level.SEVERE, null, ex);
}
}
@Override
public void start(Stage primaryStage) {
TextArea posts= new TextArea();
VBox vertical_layout=new VBox();
ObservableList list_v = vertical_layout.getChildren();
list_v.add(posts);
posts.setPrefRowCount(700);
posts.setPrefColumnCount(700);
Scene scene = new Scene(vertical_layout, 1000, 1000);
primaryStage.setTitle("Posts Window");
primaryStage.setScene(scene);
primaryStage.show();
updateUI(posts);
}
/**
*
* @param posts
*/
public void updateUI(TextArea posts){
try {
String query="select answer from records where id="+counter+";";
rs=stmt.executeQuery(query);
if(rs.first()){
//System.out.println("Got record : "+rs.getString(1));
posts.setText(rs.getString(1));
}
} catch (SQLException ex) {
Logger.getLogger(Posts_Window.class.getName()).log(Level.SEVERE, null, ex);
}
}
}