Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. package worksheet3;
  2.  
  3. import java.io.*;
  4. import java.sql.*;
  5.  
  6. public class query1 {
  7. public static void main(String[] args) throws IOException{
  8. try {
  9. Class.forName("com.mysql.jdbc.Driver");
  10. Connection c = DriverManager.getConnection(
  11. "jdbc:mysql://localhost:3306/db_na8g09", "na8g09", "");
  12. Statement s = c.createStatement();
  13. s.executeQuery("select * from tb01");
  14. ResultSet r = s.getResultSet();
  15. while(r.next()) {
  16. System.out.println(r.getString("fld01") + " " + r.getString("fld02"));
  17. }
  18. } catch(Exception e) {
  19. System.err.println("Error: " + e.toString());
  20. }
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement