Advertisement
Guest User

Untitled

a guest
Mar 29th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. package com.control;
  2. import java.sql.*;
  3. public class DBHelper
  4. {
  5. Connection conn;
  6. Statement st;
  7. ResultSet rs;
  8. public DBHelper()throws ClassNotFoundException
  9. {
  10. Class.forName("oracle.jdbc.driver.OracleDriver");
  11. }
  12.  
  13. public boolean getConnection()throws SQLException
  14. {
  15. conn=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","system");
  16. if(conn!=null)
  17. return true;
  18. return false;
  19. }
  20.  
  21. public void execute(String query)throws SQLException
  22. {
  23. st=conn.createStatement();
  24. st.execute(query);
  25.  
  26. }
  27.  
  28.  
  29. public static void main(String args[])throws Exception
  30. {
  31.  
  32. DBHelper db=new DBHelper();
  33. if(db.getConnection())
  34. {
  35. System.out.println("Logged In");
  36. }
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement