Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package oarcle;
- import java.sql.DriverManager;
- import java.sql.ResultSet;
- import java.sql.Connection;
- import java.sql.SQLException;
- import java.sql.Statement;
- public class OracleJDBCExample {
- public static void main(String[] argv) throws SQLException {
- System.out.println("Merhaba Dünya \n Artık java biliyorum :))\n");
- Connection connection = null;
- System.out.println("-------- Oracle JDBC Connection Testing ------\n");
- System.out.println("Oracle JDBC Driver Registered!\n");
- try {
- connection = DriverManager.getConnection(
- "jdbc:oracle:thin:@localhost:1521:xe", "hr", "hr");
- } catch (SQLException e) {
- System.out.println("Connection Failed! Check output console");
- e.printStackTrace();
- return;
- }
- if (connection != null) {
- System.out.println("Veri Tabanına Erişim Sağlandı");
- } else {
- System.out.println("Failed to make connection!");
- }
- System.out.println("ID NAME SURNAME");
- Statement stmt=connection.createStatement();
- ResultSet rs=stmt.executeQuery("select * from Employees");
- while(rs.next())
- System.out.println(rs.getInt(1)+" "+rs.getString(2)+" "+rs.getString(3));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement