Advertisement
Guest User

Untitled

a guest
May 25th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.22 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.     }
  25.     catch(SQLException e){
  26.     e.printStackTrace();
  27.     }
  28.  }
  29.  
  30. public static void motorSelect(){
  31.          try {
  32.          Statement stmt = conn.createStatement();
  33.          ResultSet rs = stmt.executeQuery("SELECT * FROM MOTORKEREKPAR");
  34.  
  35.          System.out.println(rs);
  36.          while (rs.next()){
  37.          //rs.next();
  38.            System.out.println(rs.getObject(1)+" "+rs.getObject(2)+" "+rs.getObject(3)+" "+rs.getObject(4)+" "+rs.getObject(5)+" "+rs.getObject(6)+" "+rs.getObject(7));
  39.          }
  40.          }
  41.          catch (SQLException e){
  42.           e.printStackTrace();
  43.         }
  44.  
  45.  
  46. }
  47.  
  48.  
  49.     public static void main(String[] args) {
  50.  
  51.         kapcsolodas();
  52.         motorSelect();
  53.  
  54.     }
  55.  
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement