Advertisement
Guest User

Untitled

a guest
Mar 24th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. public class Com {
  2.  
  3. public static Connection getConnection(){
  4. Connection conn = null;
  5. try{
  6. Class.forName("oracle.jdbc.driver.OracleDriver");
  7. conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1522:orcl", "SH12", "121212");
  8.  
  9. }catch (Exception e) {
  10. e.printStackTrace();
  11. }
  12. return conn;
  13. }
  14.  
  15.  
  16. public static void closeConnection(Connection conn){
  17. try{
  18. if(conn != null){
  19. if(!conn.isClosed()){
  20. conn.close();
  21. }
  22. }
  23. }catch (Exception e) {
  24. e.printStackTrace();
  25. }
  26. }
  27.  
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement