Guest User

Untitled

a guest
Dec 15th, 2018
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1.  
  2. import java.sql.*;
  3.  
  4. /*
  5. * To change this template, choose Tools | Templates
  6. * and open the template in the editor.
  7. */
  8.  
  9. /**
  10. *
  11. * @author Jiří
  12. */
  13. public class OracleConnection1 {
  14. public static void main(String[] args) throws ClassNotFoundException, SQLException {
  15. String userName = "st25412";
  16. String password = "st25412";
  17.  
  18. Connection connection = null;
  19. Statement statement = null;
  20. ResultSet resultSet = null;
  21.  
  22. Class c = Class.forName("oracle.jdbc.OracleDriver");
  23. System.out.println("Load driver class: " + c);
  24.  
  25. connection = DriverManager.getConnection("jdbc:oracle:thin:@sql101.upceucebny.cz:1521:oracle10", userName, password);
  26. // connection = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", userName, password);
  27. connection.setAutoCommit(true);
  28.  
  29. statement = connection.createStatement();
  30. resultSet = statement.executeQuery("select id, nazev, rokstartu, stat from serialy order by id");
  31.  
  32. while (resultSet.next())
  33. System.out.println(resultSet.getString(1) + ". " + resultSet.getString(2) + "(" + resultSet.getString(3) + ")");
  34.  
  35. resultSet.close();
  36. statement.close();
  37. connection.close();
  38. }
  39. }
Add Comment
Please, Sign In to add comment