Guest User

Untitled

a guest
May 22nd, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. import java.sql.DriverManager;
  2. import java.sql.PreparedStatement;
  3. import java.sql.ResultSet;
  4.  
  5.  
  6. public class testing{
  7.  
  8. public static void main(String[] args) throws Exception
  9. {
  10.  
  11. Class.forName("com.mysql.jdbc.Driver");
  12.  
  13. java.sql.Connection con= DriverManager.getConnection("jdbc:mysql://localhost/projectjava","interview","password");
  14.  
  15. PreparedStatement statement = con.prepareStatement("select * from names");
  16.  
  17. ResultSet result = statement.executeQuery();
  18.  
  19. while (result.next())
  20. {
  21.  
  22. System.out.println("<html>" +
  23. "<head><title>Books</title></head>" +
  24. "<body>" +
  25. "Hi" +
  26. "</body>" +
  27. "</html>");
  28.  
  29. System.out.println(result.getString(1) + " " + result.getString(2));
  30.  
  31. }
  32. }
  33. }
Add Comment
Please, Sign In to add comment