SHARE
TWEET

Untitled

a guest May 21st, 2017 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. package javaapplication1;
  3.  
  4. import java.sql.*;
  5.  
  6.  
  7. public class DatabaseClass {
  8.    
  9.     private String DBURL = "jdbc:mysql://localhost:3306/myjpm?user=root&password=";
  10.      
  11.      Connection con = null;
  12.      Statement st = null;
  13.      ResultSet rs = null;
  14.    
  15.     public DatabaseClass(){
  16.         System.out.println("Making Connection to Database Server");
  17.         try {
  18.             con = DriverManager.getConnection(DBURL);
  19.         } catch ( SQLException e ){
  20.             e.printStackTrace();
  21.         }
  22.     }
  23.    
  24.    
  25.     public void ExcuteSQL(String vSQL){
  26.        
  27.         try {
  28.             st = con.createStatement();
  29.             st.execute(vSQL);
  30.         } catch ( SQLException e){
  31.             e.printStackTrace();
  32.         }
  33.     }
  34.    
  35.     public ResultSet GetResults(String vSQL){
  36.        
  37.         try{
  38.             st = con.createStatement();
  39.             rs = st.executeQuery(vSQL);
  40.         }catch(SQLException e){
  41.             e.printStackTrace();
  42.         }
  43.        
  44.         return rs;
  45.     }
  46.    
  47.    
  48.    
  49.    
  50. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top