Advertisement
Guest User

Untitled

a guest
May 25th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.14 KB | None | 0 0
  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5.  
  6. package beadando;
  7. import java.sql.*;
  8.  
  9. /**
  10.  *
  11.  * @author Levente
  12.  */
  13. public class Main {
  14.  static Connection conn;
  15.  
  16.     /**
  17.      * @param args the command line arguments
  18.      */
  19. public static void kapcsolodas(){
  20.     try{
  21.     DriverManager.registerDriver(
  22.     new oracle.jdbc.driver.OracleDriver());
  23.     conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521/XE","leva","xi1edil2");
  24.     conn.close();
  25.     }
  26.     catch(SQLException e){
  27.     e.printStackTrace();
  28.     }
  29.  }
  30.  
  31. public static void motorSelect(){
  32.          try {
  33.          Statement stmt = conn.createStatement();
  34.          ResultSet rs = stmt.executeQuery("SELECT * FROM MOTORKEREKPAR");
  35.  
  36.          System.out.println(rs);
  37.          while (rs.next()){
  38.          //rs.next();
  39.            System.out.println(rs.getObject(1)+" "+rs.getObject(2));
  40.          }
  41.          }
  42.          catch (SQLException e){
  43.           e.printStackTrace();
  44.         }
  45.  
  46.  
  47. }
  48.  
  49.  
  50.     public static void main(String[] args) {
  51.  
  52.         kapcsolodas();
  53.         motorSelect();
  54.  
  55.     }
  56.  
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement