-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdisplay.java
119 lines (71 loc) · 3.06 KB
/
display.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
package sample;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import sample.ConnectionClass;
import sample.modeltable;
import java.net.URL;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Observable;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
public class display implements Initializable{
@FXML
private TableView<modeltable> table;
@FXML
private TableColumn<modeltable, String> name;
@FXML
private TableColumn<modeltable, String> designation;
@FXML
private TableColumn<modeltable, String> gender;
@FXML
private TableColumn<modeltable, String> age;
@FXML
private TableColumn<modeltable, String> contact;
@FXML
private TableColumn<modeltable, String> emailid;
@FXML
private TableColumn<modeltable, String> address;
ObservableList<modeltable> oblist= FXCollections.observableArrayList();
@Override
public void initialize(URL location, ResourceBundle resources) {
try {
ConnectionClass connectionClass = new ConnectionClass();
Connection connection = connectionClass.getConnection();
// ResultSet rs = connection.createStatement().executeQuery("select * from registers");
Statement query= connection.createStatement();
ResultSet rs=query.executeQuery("select * from elms.registers");
while (rs.next()) {
//String tab=rs.getString("name");
//System.out.println(tab);
oblist.add(new modeltable(rs.getString("name"),rs.getString("designation"),rs.getString("gender"),rs.getString("age"),rs.getString("contact"),rs.getString("emailid"),rs.getString("address")));
}
}
catch(SQLException ex){
Logger.getLogger(display.class.getName()).log(Level.SEVERE,null,ex);
}
name.setCellValueFactory(new PropertyValueFactory<>("name"));
designation.setCellValueFactory(new PropertyValueFactory<>("designation"));
gender.setCellValueFactory(new PropertyValueFactory<>("gender"));
age.setCellValueFactory(new PropertyValueFactory<>("age"));
contact.setCellValueFactory(new PropertyValueFactory<>("contact"));
emailid.setCellValueFactory(new PropertyValueFactory<>("emailid"));
address.setCellValueFactory(new PropertyValueFactory<>("address"));
table.setItems(oblist);
}
}
/*
Statement statement=connection.createStatement();
String sql="insert into register"+"(name,mob,id)"+"values('"+names.getText()+"',"+ages+",210)";
statement.executeUpdate(sql);
System.out.println("done");
*/