Advertisement
Guest User

Untitled

a guest
May 22nd, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. import java.sql.*;
  2.  
  3. import javax.swing.JOptionPane;
  4.  
  5. public class JDBC {
  6. static final String driver = "com.jdbc.mysql.Driver";
  7. static final String url = "jdbc:mysql://192.168.105.254/JAVATEST?user=max&password=test";
  8. try{
  9. Class.forName(driver);
  10. }catch(java.lang.ClassNotFoundException e){
  11. System.out.println("error");
  12. }
  13. try{
  14. Connection con=DriverManager.getConnection(url);
  15. String reply=JOptionPane.showInputDialog("Inserisci un intero x");
  16. PreparedStatement pquery= con.prepareStatement("Select Nome,Cognome from Socio where Matricola in(Select Socio,Count(Volume) from Prestito group by Socio having Count(Volume)>=?");
  17. pquery.setString(1,reply);
  18. ResultSet result = pquery.executeQuery();
  19. }catch(SQLException ex){
  20. System.out.println("sql sintax error");
  21. }
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement