SHARE
TWEET

Untitled

a guest Jun 15th, 2017 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import com.mysql.jdbc.*;
  2. import java.sql.*;
  3.  
  4. public class dbfile
  5. {
  6.         public static void main(String[] args)
  7.         {
  8.                 DB db = new DB();
  9.                 Connection conn=db.dbConnect(
  10.                   "jdbc:mysql://nyctelecomm.com:3306/test", "brads",
  11. "andreasd");
  12.         }
  13.  
  14. }
  15.  
  16. class DB
  17. {
  18.         public DB() {}
  19.  
  20.         public Connection dbConnect(String db_connect_string,
  21.           String db_userid, String db_password)
  22.         {
  23.                 try
  24.                 {
  25.  
  26. Class.forName("com.mysql.jdbc.Driver").newInstance();
  27.                         Connection conn = DriverManager.getConnection(
  28.                           db_connect_string, db_userid, db_password);
  29.  
  30.                         System.out.println("connected");
  31.                         return conn;
  32.  
  33.                 }
  34.                 catch (Exception e)
  35.                 {
  36.                         e.printStackTrace();
  37.                         return null;
  38.                 }
  39.         }
  40. }
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