Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.control;
- import java.sql.*;
- public class DBHelper
- {
- Connection conn;
- Statement st;
- ResultSet rs;
- public DBHelper()throws ClassNotFoundException
- {
- Class.forName("oracle.jdbc.driver.OracleDriver");
- }
- public boolean getConnection()throws SQLException
- {
- conn=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","system");
- if(conn!=null)
- return true;
- return false;
- }
- public void execute(String query)throws SQLException
- {
- st=conn.createStatement();
- st.execute(query);
- }
- public static void main(String args[])throws Exception
- {
- DBHelper db=new DBHelper();
- if(db.getConnection())
- {
- System.out.println("Logged In");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement