1

「ResultSet.TYPE_SCROLL_INSENSITIVE、ResultSet.CONCUR_UPDATABLE」を設定すると、アプリを実行すると、アプリのGuiが表示されません。MS Access データベース接続に Ucanaccess ドライバーを使用しています。問題はどこだ?助けてください...

ここに私のコードがあります:

package javadatabase;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;


public class gui extends Db{

    JFrame fr;
    JLabel fname;
    JLabel lname;
    JLabel age;

    JTextField fntext;
    JTextField lntext;
    JTextField agetext;

    JButton next = new JButton("Next");
    JButton prev = new JButton("Prev");
    JButton first = new JButton("First");
    JButton last = new JButton("Last");



    public gui(){

        frame();
    }

    public void frame(){
        fr = new JFrame();
        fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        fr.setSize(600, 400);
        fr.setVisible(true);

        fname = new JLabel("نوم:  ");
        lname = new JLabel ("تخلص:  ");
        age = new JLabel ("عمر:  ");


        fntext = new JTextField(20);
        lntext = new JTextField(20);
        agetext = new JTextField(20);


        JPanel panel = new JPanel();
        panel.add(fntext);
        panel.add(fname);
        panel.add(lntext);
        panel.add(lname);
        panel.add(agetext);
        panel.add(age);

        panel.add(next);
        panel.add(prev);
        panel.add(first);
        panel.add(last);


        fr.add(panel);

       try{ 
        rs.next();
        fntext.setText(rs.getString("Fname"));
        lntext.setText(rs.getString("Lname"));
        agetext.setText(rs.getString("Age"));


       }catch(Exception ex){}



    }
}

ここに私のメインクラスがあります:

package javadatabase;

import java.sql.*;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;


public  class Db {

    Connection con;
    Statement st;
    ResultSet rs;

    public Db(){

        connect();
    }


    public void connect(){

        try{
        con = DriverManager.getConnection("jdbc:ucanaccess://d:\\\\netbeansProjects\\\\db1.accdb");
        st = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
        String sql = "select * from Table1";
        rs = st.executeQuery(sql);

        }catch(Exception ex) {}
    }     


    public static void main(String[] args) {

        //Look and feel
            try {UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());}
            catch (ClassNotFoundException e) {}
            catch (InstantiationException e) {}
            catch (IllegalAccessException e) {}
            catch (UnsupportedLookAndFeelException e) {}

        SwingUtilities.invokeLater(new Runnable() {

                public void run() {
                    new Db();
                    new gui();

                }


                }); 


    }

}
4

0 に答える 0