Searching between dates in SQL with JDBC?

前端 未结 3 1926
悲哀的现实
悲哀的现实 2020-12-03 18:55

I\'m currently writing a Java Swing application that reads data in from a MYOB database file and displays certain information in a table. I\'ve been able to successfully gen

3条回答
  •  悲&欢浪女
    2020-12-03 19:19

    Class.forName("com.mysql.jdbc.Driver");
    
    connection=DriverManager.getConnection("jdbc:mysql://localhost:3306/hospitall","root","");
    
    PreparedStatement ps=connection.prepareStatement("select * from patient where patientid='"+txtpatientid.getText()+"'");
    
    Statement stm=connection.createStatement();
    
    ResultSet rs=ps.executeQuery();
    
    if(rs.next()){
    
    String patientid=txtpatientid.getText(); 
    
    String str="select * from patient where patientid='"+patientid+"'";
    
    ResultSet result=stm.executeQuery(str);
    

提交回复
热议问题