Python中文网

一个关于 编程问题的解答网站.

有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

按下按钮时,java在数据库的表中搜索信息

我在找一张桌子。当我在“姓名”栏中搜索姓名时,当我运行该程序时,在搜索框中对babar进行fx搜索时,程序会显示该列名不存在

try {     
    //        Class.forName("oracle.jdbc.driver.OracleDriver");
            String URL = "jdbc:derby://localhost:1527/BOBSHOP";
            String Username = "babar";`enter code here`
            String Password = "babar";
            String DB_DRIVER = "oracle.jdbc.driver.OracleDriver";
            Connection con2 = DriverManager.getConnection(URL, Username, Password);

            //String sql = "Select * FROM \"Kundetabel\" WHERE navn =?";
            //String sql = "select * from BABAR.\"Kundetabel\" WHERE navn=?";
            String sql = "SELECT * FROM \"Kundetabel\" WHERE navn LIKE '%navn%'";

            pst = con2.prepareStatement(sql);
            pst.setString(1,sogeTextField1.getText());

            String sognavn = sogeTextField1.getText();

            rs=pst.executeQuery();
            if(rs.next()){
            String add1=rs.getString("kundeID");
            sogedisplayTextField1.setText(add1);
            String add2=rs.getString("navn");
            sogedisplayTextField2.setText(add2);
            String add3=rs.getString("efternavn");
            sogedisplayTextField3.setText(add3);
            String add4=rs.getString("adresse");
            sogedisplayTextField4.setText(add4);
            String add5=rs.getString("email");
            sogedisplayTextField5.setText(add5);
            String add6=rs.getString("telefonnr");
            sogedisplayTextField6.setText(add6);
            String add7=rs.getString("kode");
            sogedisplayTextField7.setText(add7);
            }
        } catch (SQLException ex) {
            Logger.getLogger(HardwareStore.class.getName()).log(Level.SEVERE, null, ex);
        }       

共 (0) 个答案