Advertisement
Guest User

Untitled

a guest
Jul 14th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. package oarcle;
  2.  
  3. import java.sql.DriverManager;
  4. import java.sql.ResultSet;
  5. import java.sql.Connection;
  6. import java.sql.SQLException;
  7. import java.sql.Statement;
  8.  
  9. public class OracleJDBCExample {
  10.  
  11.  
  12. public static void main(String[] argv) throws SQLException {
  13. System.out.println("Merhaba Dünya \n Artık java biliyorum :))\n");
  14.  
  15.  
  16. Connection connection = null;
  17.  
  18. System.out.println("-------- Oracle JDBC Connection Testing ------\n");
  19.  
  20.  
  21. System.out.println("Oracle JDBC Driver Registered!\n");
  22.  
  23.  
  24.  
  25.  
  26. try {
  27.  
  28. connection = DriverManager.getConnection(
  29. "jdbc:oracle:thin:@localhost:1521:xe", "hr", "hr");
  30.  
  31. } catch (SQLException e) {
  32.  
  33. System.out.println("Connection Failed! Check output console");
  34. e.printStackTrace();
  35. return;
  36.  
  37. }
  38.  
  39. if (connection != null) {
  40. System.out.println("Veri Tabanına Erişim Sağlandı");
  41. } else {
  42. System.out.println("Failed to make connection!");
  43. }
  44. System.out.println("ID NAME SURNAME");
  45. Statement stmt=connection.createStatement();
  46. ResultSet rs=stmt.executeQuery("select * from Employees");
  47. while(rs.next())
  48. System.out.println(rs.getInt(1)+" "+rs.getString(2)+" "+rs.getString(3));
  49. }
  50.  
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement