作成した GUI からデータベースにデータを送信すると、データはそこに保存されますが、リコールしようとしても何も起こりません。また、作成された結果セットは、Java がデータベースに接続したときに保存されたレコードのみを取得することに気付きました。たとえば、結果セットが作成されたときに 500 レコードが特定のデータベース テーブルにある場合、それらの 500 レコードのみを追加で取得できます。追加されたレコードを取得できます。
私は必死になっているすべてを試しましたが、助けが必要であるか、正しい方向に向けてください
レコードの取得を担当するボタンのコード スニペットを次に示します。
JButton btncanel = new JButton("Submit");
btncanel.setBounds(820, 300, 80, 30);
btncanel.setFont(new Font("Times New Roman", Font.BOLD,12));
panel.add(btncanel);
btncanel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (scat3.getSelectedIndex() == 1) {
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String FILE = "jdbc:odbc:Usermbj";
Connection pcon = DriverManager.getConnection(FILE);
java.sql.Statement pt = pcon.createStatement();
ResultSet result = pt.executeQuery("SELECT * FROM Airlines2");
while (result.next()) {
String LN = result.getString(3);
String FN = result.getString(4);
String COMP = result.getString(12);
int RAPnum = result.getInt(1);
String EH = result.getString(2);
String FRP = result.getString(5);
String ROD = result.getString(6);
int RS = result.getInt(7);
String OD = result.getString(8);
int OS = result.getInt(9);
String COOD =result.getString(10);
String AS = result.getString(11);
if ((scat2.getSelectedIndex() == 1 && crit.getText().equals(LN))
&& (scat4.getSelectedIndex() == 1 && c.getText().equals(FN))) {
JOptionPane.showMessageDialog(null,
"Employment History----------" + " " + " " + EH + "\n\n"
+ "Rap Code----------" + " " + " " + RAPnum + "\n\n"
+ "First Name----------" + " " + " " + FN + "\n\n"
+ "Last Name----------" + " " + " " + LN + "\n\n"
+ "Finger Print Record----------" + " " + " " + FRP + "\n\n"
+ "Re-Orientation Date----------" + " " + " " + ROD + "\n\n"
+ "Re-Orientation Score----------" + " " + " " + RS + "\n\n"
+ "Oreintation Date----------" + " " + " " + OD + "\n\n"
+ "Orientation Score----------" + " " + " " + OS + "\n\n"
+ "Coodintors----------" + " " + " " + COOD + "\n\n"
+ "Applicant Gender----------" + " " + " " + AS + "\n\n"
+ "Company----------" + " " + " " + COMP);
lnam.setText(LN);
fnam.setText(FN);
comp.setText(COMP);
empn.setText(String.valueOf(RAPnum));
scat.setText(EH);
fpr1.setText(FRP);
reod.setText(ROD);
reos.setText(String.valueOf(RS));
od.setText(OD);
os.setText(String.valueOf(OS));
cood.setText(COOD);
scat1.setText(AS);
}
if ((scat2.getSelectedIndex() == 1 && crit.getText().equals(LN))
&& (c.getText().equals(""))) {
JOptionPane.showMessageDialog(null,
"Employment History----------" + " " + " " + EH + "\n\n"
+ "Rap Code----------" + " " + " " + RAPnum + "\n\n"
+ "First Name----------" + " " + " " + FN + "\n\n"
+ "Last Name----------" + " " + " " + LN + "\n\n"
+ "Finger Print Record----------" + " " + " " + FRP + "\n\n"
+ "Re-Orientation Date----------" + " " + " " + ROD + "\n\n"
+ "Re-Orientation Score----------" + " " + " " + RS + "\n\n"
+ "Oreintation Date----------" + " " + " " + OD + "\n\n"
+ "Orientation Score----------" + " " + " " + OS + "\n\n"
+ "Coodintors----------" + " " + " " + COOD + "\n\n"
+ "Applicant Gender-----------" + " " + " " + AS + "\n\n"
+ "Company----------" + " " + " " + COMP);
lnam.setText(LN);
fnam.setText(FN);
comp.setText(COMP);
empn.setText(String.valueOf(RAPnum));
scat.setText(EH);
fpr1.setText(FRP);
reod.setText(ROD);
reos.setText(String.valueOf(RS));
od.setText(OD);
os.setText(String.valueOf(OS));
cood.setText(COOD);
scat1.setText(AS);
}
if ((scat4.getSelectedIndex() == 1 && c.getText().equals(FN))
&&(crit.getText().equals(""))) {
JOptionPane.showMessageDialog(null,
"Employment History----------" + " " + " " + EH + "\n\n"
+ "Rap Code----------" + " " + " " + RAPnum + "\n\n"
+ "First Name----------" + " " + " " + FN + "\n\n"
+ "Last Name----------" + " " + " " + LN + "\n\n"
+ "Finger Print Record----------" + " " + " " + FRP + "\n\n"
+ "Re-Orientation Date----------" + " " + " " + ROD + "\n\n"
+ "Re-Orientation Score----------" + " " + " " + RS + "\n\n"
+ "Oreintation Date----------" + " " + " " + OD + "\n\n"
+ "Orientation Score----------" + " " + " " + OS + "\n\n"
+ "Coodintors-----------" + " " + " " + COOD + "\n\n"
+ "Applicant Gender----------" + " " + " " + AS + "\n\n"
+ "Company----------" + " " + " " + COMP);
lnam.setText(LN);
fnam.setText(FN);
comp.setText(COMP);
empn.setText(String.valueOf(RAPnum));
scat.setText(EH);
fpr1.setText(FRP);
reod.setText(ROD);
reos.setText(String.valueOf(RS));
od.setText(OD);
os.setText(String.valueOf(OS));
cood.setText(COOD);
scat1.setText(AS);
}
}
} catch(Exception g) {
g.printStackTrace();
}
} else if (scat3.getSelectedIndex() == 2) {
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String FILE = "jdbc:odbc:Usermbj";
Connection pcon = DriverManager.getConnection(FILE);
java.sql.Statement qt = pcon.createStatement();
ResultSet result = qt.executeQuery("SELECT * FROM Concessionaire1");
while (result.next()) {
String LN = result.getString(3);
String FN = result.getString(4);
String COMP = result.getString(12);
int RAPnum = result.getInt(2);
String EH = result.getString(1);
String FRP = result.getString(5);
String ROD = result.getString(6);
int RS = result.getInt(7);
String OD = result.getString(8);
int OS = result.getInt(9);
String COOD =result.getString(10);
String AS = result.getString(11);
if ((scat2.getSelectedIndex() == 1 && crit.getText().equals(LN))
&& (scat4.getSelectedIndex() == 1 && c.getText().equals(FN))) {
JOptionPane.showMessageDialog(null,
"Employment History----------" + " " + " " + EH + "\n\n"
+ "Rap Code----------" + " " + " " + RAPnum + "\n\n"
+ "First Name----------" + " " + " " + FN + "\n\n"
+ "Last Name----------" + " " + " " + LN + "\n\n"
+ "Finger Print Record----------" + " " + " " + FRP + "\n\n"
+ "Re-Orientation Date----------" + " " + " " + ROD + "\n\n"
+ "Re-Orientation Score----------" + " " + " " + RS + "\n\n"
+ "Oreintation Date----------" + " " + " " + OD + "\n\n"
+ "Orientation Score----------" + " " + " " + OS + "\n\n"
+ "Coodintors----------" + " " + " " + COOD + "\n\n"
+ "Applicant Gender----------" + " " + " " + AS + "\n\n"
+ "Company----------" + " " + " " + COMP);
lnam.setText(LN);
fnam.setText(FN);
comp.setText(COMP);
empn.setText(String.valueOf(RAPnum));
scat.setText(EH);
fpr1.setText(FRP);
reod.setText(ROD);
reos.setText(String.valueOf(RS));
od.setText(OD);
os.setText(String.valueOf(OS));
cood.setText(COOD);
scat1.setText(AS);
}
if ((scat2.getSelectedIndex() == 1 && crit.getText().equals(LN))
&&(c.getText().equals(""))){
JOptionPane.showMessageDialog(null,
"Employment History----------" + " " + " " + EH + "\n\n"
+ "Rap Code----------" + " " + " " + RAPnum + "\n\n"
+ "First Name----------" + " " + " " + FN + "\n\n"
+ "Last Name----------" + " " + " " + LN + "\n\n"
+ "Finger Print Record----------" + " " + " " + FRP + "\n\n"
+ "Re-Orientation Date----------" + " " + " " + ROD + "\n\n"
+ "Re-Orientation Score----------" + " " + " " + RS + "\n\n"
+ "Oreintation Date----------" + " " + " " + OD + "\n\n"
+ "Orientation Score----------" + " " + " " + OS + "\n\n"
+ "Coodintors----------" + " " + " " + COOD + "\n\n"
+ "Applicant Gender----------" + " " + " " + AS + "\n\n"
+ "Company----------" + " " + " " + COMP);
lnam.setText(LN);
fnam.setText(FN);
comp.setText(COMP);
empn.setText(String.valueOf(RAPnum));
scat.setText(EH);
fpr1.setText(FRP);
reod.setText(ROD);
reos.setText(String.valueOf(RS));
od.setText(OD);
os.setText(String.valueOf(OS));
cood.setText(COOD);
scat1.setText(AS);
}
if ((scat4.getSelectedIndex() == 1 && c.getText().equals(FN))
&&(crit.getText().equals(""))) {
JOptionPane.showMessageDialog(null,
"Employment History----------" + " " + " " + EH + "\n\n"
+ "Rap Code----------" + " " + " " + RAPnum + "\n\n"
+ "First Name----------" + " " + " " + FN + "\n\n"
+ "Last Name----------" + " " + " " + LN + "\n\n"
+ "Finger Print Record----------" + " " + " " + FRP + "\n\n"
+ "Re-Orientation Date----------" + " " + " " + ROD + "\n\n"
+ "Re-Orientation Score----------" + " " + " " + RS + "\n\n"
+ "Oreintation Date----------" + " " + " " + OD + "\n\n"
+ "Orientation Score----------" + " " + " " + OS + "\n\n"
+ "Coodintors----------" + " " + " " + COOD + "\n\n"
+ "Applicant Gender----------" + " " + " " + AS + "\n\n"
+ "Company----------" + " " + " " + COMP);
lnam.setText(LN);
fnam.setText(FN);
comp.setText(COMP);
empn.setText(String.valueOf(RAPnum));
scat.setText(EH);
fpr1.setText(FRP);
reod.setText(ROD);
reos.setText(String.valueOf(RS));
od.setText(OD);
os.setText(String.valueOf(OS));
cood.setText(COOD);
scat1.setText(AS);
}
}
} catch (Exception g) {
g.printStackTrace();
}
}
}
});