Advertisement
Guest User

Untitled

a guest
May 7th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. package com.company;
  2. import java.sql.*;
  3.  
  4. public class Main {
  5.  
  6. public ResultSet executeQuery(String Query,Connection con){
  7. ResultSet rs;
  8. try (Statement stmt = con.createStatement()) {
  9. rs = stmt.executeQuery(Query);
  10. return rs;
  11. } catch (SQLException e1) {
  12. e1.printStackTrace();
  13. }
  14. return (null);
  15. }
  16.  
  17. public static void main(String[] args) {
  18. try{
  19.  
  20. Class.forName("oracle.jdbc.driver.OracleDriver");
  21. Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","oracle");
  22. Statement stmt=con.createStatement();
  23.  
  24. con.close();
  25.  
  26. }catch(Exception e){ System.out.println(e);}
  27.  
  28. }
  29.  
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement